Skip to content

Commit

Permalink
Scripts: Align default engines for check-engines with the package (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo authored Jan 12, 2021
1 parent 3de1114 commit 04aec01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
4 changes: 4 additions & 0 deletions packages/scripts/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
- Make it possible to transpile `.jsx` files with `build` and `start` commands ([#28002](https://github.com/WordPress/gutenberg/pull/28002)).
- Add support for static assets (fonts and images) for `build` and `start` commands ([#28043](https://github.com/WordPress/gutenberg/pull/28043)).

### Bug Fix

- Ensure that `check-engines` uses the same default version of Node.js and npm as this package ([#28143](https://github.com/WordPress/gutenberg/pull/28143)).

### Internal

- The bundled `webpack-bundle-analyzer` dependency has been updated from requiring `^3.6.1` to requiring `^4.2.0`.
Expand Down
2 changes: 1 addition & 1 deletion packages/scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ This is how you execute the script with presented setup:

#### Advanced information

It uses [check-node-version](https://www.npmjs.com/package/check-node-version) behind the scenes with the recommended configuration provided. Similarly to this package, the default requirements are `node` 10.0.0 or later, and `npm` 6.9.0 or later. You can specify your own ranges as described in [check-node-version docs](https://www.npmjs.com/package/check-node-version). Learn more in the [Advanced Usage](#advanced-usage) section.
It uses [check-node-version](https://www.npmjs.com/package/check-node-version) behind the scenes with the recommended configuration provided. The default requirements are set to the same Node.js and npm versions as listed in the [installation](#installation) section for this package. You can specify your own ranges as described in [check-node-version docs](https://www.npmjs.com/package/check-node-version). Learn more in the [Advanced Usage](#advanced-usage) section.

### `check-licenses`

Expand Down
24 changes: 16 additions & 8 deletions packages/scripts/scripts/check-engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@ const { sync: resolveBin } = require( 'resolve-bin' );
*/
const { getArgsFromCLI, hasArgInCLI } = require( '../utils' );

const args = getArgsFromCLI();
const getConfig = () => {
const hasConfig =
hasArgInCLI( '--package' ) ||
hasArgInCLI( '--node' ) ||
hasArgInCLI( '--npm' ) ||
hasArgInCLI( '--yarn' );

const hasConfig =
hasArgInCLI( '--package' ) ||
hasArgInCLI( '--node' ) ||
hasArgInCLI( '--npm' ) ||
hasArgInCLI( '--yarn' );
const config = ! hasConfig ? [ '--node', '>=10.0.0', '--npm', '>=6.9.0' ] : [];
if ( hasConfig ) {
return [];
}
const {
engines: { node, npm },
} = require( '../package.json' );

return [ '--node', node, '--npm', npm ];
};

const result = spawn(
resolveBin( 'check-node-version' ),
[ ...config, ...args ],
[ ...getConfig(), ...getArgsFromCLI() ],
{
stdio: 'inherit',
}
Expand Down

0 comments on commit 04aec01

Please sign in to comment.