Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Align default engines for check-engines with the package #28143

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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