Skip to content

Commit

Permalink
build:package-types: Run silently to reduce user confusion
Browse files Browse the repository at this point in the history
Follows up on #61501.

The original PR, #61501, modified the `build:package-types` script to
log a help message to developers if the `tsc --build` call failed. This
message suggested a fix (to run `npm run clean:package-types`).

This works, but due to the way that NPM logs the execution of successive
NPM scripts, the code that conditionally outputs the help message is,
itself, always output. This is not only noisy, but could mislead
developers into following the help message's instruction unnecessarily.

This commit fixes the problem by wrapping the original NPM script in a
new script, which is then called with NPM's `--silent` flag. The console
output now looks like this:

> gutenberg@18.3.0 build:packages
> npm run build:package-types && node ./bin/packages/build.js

> gutenberg@18.3.0 build:package-types
> npm run --silent build:package-types:verbose
  • Loading branch information
mcsf committed May 9, 2024
1 parent dbd6bda commit 8936853
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@
"scripts": {
"build": "npm run build:packages && wp-scripts build",
"build:analyze-bundles": "npm run build -- --webpack-bundle-analyzer",
"build:package-types": "node ./bin/packages/validate-typescript-version.js && ( tsc --build || ( echo 'tsc failed. Try cleaning up first: `npm run clean:package-types`'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js",
"build:package-types": "npm run --silent build:package-types:verbose",
"build:package-types:verbose": "node ./bin/packages/validate-typescript-version.js && ( tsc --build || ( echo 'tsc failed. Try cleaning up first: `npm run clean:package-types`'; exit 1 ) ) && node ./bin/packages/check-build-type-declaration-files.js",
"prebuild:packages": "npm run clean:packages && lerna run build",
"build:packages": "npm run build:package-types && node ./bin/packages/build.js",
"build:plugin-zip": "bash ./bin/build-plugin-zip.sh",
Expand Down

0 comments on commit 8936853

Please sign in to comment.