Skip to content

Commit f798194

Browse files
feat: add load-chalk hook to initialize chalk for CLI commands
1 parent 0f16186 commit f798194

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
@@ -81,6 +81,9 @@
8181
"license": "MIT",
8282
"oclif": {
8383
"commands": "./lib/commands",
84+
"hooks": {
85+
"init": ["./lib/hooks/init/load-chalk"]
86+
},
8487
"bin": "csdx",
8588
"repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-import/<%- commandPath %>"
8689
},
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)