diff --git a/packages/contentstack-export/package.json b/packages/contentstack-export/package.json index 62524ab80..168752d84 100644 --- a/packages/contentstack-export/package.json +++ b/packages/contentstack-export/package.json @@ -82,6 +82,9 @@ "main": "./lib/commands/cm/stacks/export.js", "oclif": { "commands": "./lib/commands", + "hooks": { + "init": ["./lib/hooks/init/load-chalk"] + }, "bin": "csdx", "devPlugins": [ "@oclif/plugin-help" diff --git a/packages/contentstack-export/src/hooks/init/load-chalk.ts b/packages/contentstack-export/src/hooks/init/load-chalk.ts new file mode 100644 index 000000000..cacc8e1bd --- /dev/null +++ b/packages/contentstack-export/src/hooks/init/load-chalk.ts @@ -0,0 +1,9 @@ +import { loadChalk } from "@contentstack/cli-utilities"; + +/** + * Ensures the cli-utilities chalk singleton is ready before commands run. + * Required when this CLI runs standalone (bin/run); when embedded under core csdx, core init also loads chalk. + */ +export default async function loadChalkHook(): Promise { + await loadChalk(); +} diff --git a/packages/contentstack-import/package.json b/packages/contentstack-import/package.json index 28c413b54..098766e4b 100644 --- a/packages/contentstack-import/package.json +++ b/packages/contentstack-import/package.json @@ -81,6 +81,9 @@ "license": "MIT", "oclif": { "commands": "./lib/commands", + "hooks": { + "init": ["./lib/hooks/init/load-chalk"] + }, "bin": "csdx", "repositoryPrefix": "<%- repo %>/blob/main/packages/contentstack-import/<%- commandPath %>" }, diff --git a/packages/contentstack-import/src/hooks/init/load-chalk.ts b/packages/contentstack-import/src/hooks/init/load-chalk.ts new file mode 100644 index 000000000..8e88c9310 --- /dev/null +++ b/packages/contentstack-import/src/hooks/init/load-chalk.ts @@ -0,0 +1,9 @@ +import { loadChalk } from '@contentstack/cli-utilities'; + +/** + * Ensures the cli-utilities chalk singleton is ready before commands run. + * Required when this CLI runs standalone (bin/run); when embedded under core csdx, core init also loads chalk. + */ +export default async function loadChalkHook(): Promise { + await loadChalk(); +}