diff --git a/packages/cli-hooks/README.md b/packages/cli-hooks/README.md index d152ca9c3..bc9d2896d 100644 --- a/packages/cli-hooks/README.md +++ b/packages/cli-hooks/README.md @@ -76,7 +76,7 @@ Below is an example `slack.json` file that overrides the default `start` hook: ```json { "hooks": { - "get-hooks": "npx -q --no-install -p @slack/cli-hooks slack-cli-get-hooks", + "get-hooks": "NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-hooks", "start": "npm run dev" } } diff --git a/packages/cli-hooks/src/get-hooks.js b/packages/cli-hooks/src/get-hooks.js index af920a5a4..e09ed498f 100755 --- a/packages/cli-hooks/src/get-hooks.js +++ b/packages/cli-hooks/src/get-hooks.js @@ -43,11 +43,13 @@ if (fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) { * @returns {SDKInterface} Information about the hooks currently supported. */ export default function getHooks() { + // NODE_NO_WARNINGS=1 silences node process warnings. These warnings can occur + // on some node version (e.g. v23.2.0) and cause invalid JSON hook responses. return { hooks: { - doctor: 'npx -q --no-install -p @slack/cli-hooks slack-cli-doctor', - 'check-update': 'npx -q --no-install -p @slack/cli-hooks slack-cli-check-update', - 'get-manifest': 'npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest', + doctor: 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-doctor', + 'check-update': 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-check-update', + 'get-manifest': 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest', start: 'npx -q --no-install -p @slack/cli-hooks slack-cli-start', }, config: { diff --git a/packages/cli-hooks/src/get-hooks.spec.js b/packages/cli-hooks/src/get-hooks.spec.js index 93527c17f..85d2c2184 100755 --- a/packages/cli-hooks/src/get-hooks.spec.js +++ b/packages/cli-hooks/src/get-hooks.spec.js @@ -6,9 +6,13 @@ import getHooks from './get-hooks.js'; describe('get-hooks implementation', async () => { it('should return scripts for required hooks', async () => { const { hooks } = getHooks(); - assert(hooks.doctor === 'npx -q --no-install -p @slack/cli-hooks slack-cli-doctor'); - assert(hooks['check-update'] === 'npx -q --no-install -p @slack/cli-hooks slack-cli-check-update'); - assert(hooks['get-manifest'] === 'npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest'); + assert(hooks.doctor === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-doctor'); + assert( + hooks['check-update'] === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-check-update', + ); + assert( + hooks['get-manifest'] === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest', + ); assert(hooks.start === 'npx -q --no-install -p @slack/cli-hooks slack-cli-start'); }); diff --git a/packages/cli-hooks/src/protocols.js b/packages/cli-hooks/src/protocols.js index dd96f6a34..b76bcc91d 100755 --- a/packages/cli-hooks/src/protocols.js +++ b/packages/cli-hooks/src/protocols.js @@ -42,7 +42,7 @@ export function DefaultProtocol(args) { // If the particular hook invocation is requesting manifest generation we // ensure any logging is a no-op to prevent littering stdout with logging // and confusing the CLI's manifest JSON payload parsing. - const loggerMethod = manifestOnly ? () => { } : console.log; + const loggerMethod = manifestOnly ? () => {} : console.log; return { name: DEFAULT_PROTOCOL, log: loggerMethod,