Skip to content

Commit c5f8ffd

Browse files
authored
fix(cli-hooks): silence node warnings that can break @slack/cli-hooks (#2096)
1 parent 278514f commit c5f8ffd

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

packages/cli-hooks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Below is an example `slack.json` file that overrides the default `start` hook:
7676
```json
7777
{
7878
"hooks": {
79-
"get-hooks": "npx -q --no-install -p @slack/cli-hooks slack-cli-get-hooks",
79+
"get-hooks": "NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-hooks",
8080
"start": "npm run dev"
8181
}
8282
}

packages/cli-hooks/src/get-hooks.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ if (fs.realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
4343
* @returns {SDKInterface} Information about the hooks currently supported.
4444
*/
4545
export default function getHooks() {
46+
// NODE_NO_WARNINGS=1 silences node process warnings. These warnings can occur
47+
// on some node version (e.g. v23.2.0) and cause invalid JSON hook responses.
4648
return {
4749
hooks: {
48-
doctor: 'npx -q --no-install -p @slack/cli-hooks slack-cli-doctor',
49-
'check-update': 'npx -q --no-install -p @slack/cli-hooks slack-cli-check-update',
50-
'get-manifest': 'npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest',
50+
doctor: 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-doctor',
51+
'check-update': 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-check-update',
52+
'get-manifest': 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest',
5153
start: 'npx -q --no-install -p @slack/cli-hooks slack-cli-start',
5254
},
5355
config: {

packages/cli-hooks/src/get-hooks.spec.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ import getHooks from './get-hooks.js';
66
describe('get-hooks implementation', async () => {
77
it('should return scripts for required hooks', async () => {
88
const { hooks } = getHooks();
9-
assert(hooks.doctor === 'npx -q --no-install -p @slack/cli-hooks slack-cli-doctor');
10-
assert(hooks['check-update'] === 'npx -q --no-install -p @slack/cli-hooks slack-cli-check-update');
11-
assert(hooks['get-manifest'] === 'npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest');
9+
assert(hooks.doctor === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-doctor');
10+
assert(
11+
hooks['check-update'] === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-check-update',
12+
);
13+
assert(
14+
hooks['get-manifest'] === 'NODE_NO_WARNINGS=1 npx -q --no-install -p @slack/cli-hooks slack-cli-get-manifest',
15+
);
1216
assert(hooks.start === 'npx -q --no-install -p @slack/cli-hooks slack-cli-start');
1317
});
1418

packages/cli-hooks/src/protocols.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function DefaultProtocol(args) {
4242
// If the particular hook invocation is requesting manifest generation we
4343
// ensure any logging is a no-op to prevent littering stdout with logging
4444
// and confusing the CLI's manifest JSON payload parsing.
45-
const loggerMethod = manifestOnly ? () => { } : console.log;
45+
const loggerMethod = manifestOnly ? () => {} : console.log;
4646
return {
4747
name: DEFAULT_PROTOCOL,
4848
log: loggerMethod,

0 commit comments

Comments
 (0)