Skip to content

Commit 75da976

Browse files
Merge pull request #141 from contentstack/fix/dx-7341-fix-chalk-load
feat: add load-chalk hook to initialize chalk for CLI commands
2 parents bc3c718 + d19c800 commit 75da976

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

packages/contentstack-export/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@
8282
"main": "./lib/commands/cm/stacks/export.js",
8383
"oclif": {
8484
"commands": "./lib/commands",
85+
"hooks": {
86+
"init": ["./lib/hooks/init/load-chalk"]
87+
},
8588
"bin": "csdx",
8689
"devPlugins": [
8790
"@oclif/plugin-help"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { loadChalk } from "@contentstack/cli-utilities";
2+
3+
/**
4+
* Ensures the cli-utilities chalk singleton is ready before commands run.
5+
* Required when this CLI runs standalone (bin/run); when embedded under core csdx, core init also loads chalk.
6+
*/
7+
export default async function loadChalkHook(): Promise<void> {
8+
await loadChalk();
9+
}

packages/contentstack-import/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@
7777
"license": "MIT",
7878
"oclif": {
7979
"commands": "./lib/commands",
80+
"hooks": {
81+
"init": ["./lib/hooks/init/load-chalk"]
82+
},
8083
"bin": "csdx",
8184
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-import/<%- commandPath %>"
8285
},
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { loadChalk } from "@contentstack/cli-utilities";
2+
3+
/**
4+
* Ensures the cli-utilities chalk singleton is ready before commands run.
5+
* Required when this CLI runs standalone (bin/run); when embedded under core csdx, core init also loads chalk.
6+
*/
7+
export default async function loadChalkHook(): Promise<void> {
8+
await loadChalk();
9+
}

0 commit comments

Comments
 (0)