Skip to content

Commit b7bda7e

Browse files
authored
Merge pull request #304 from ckeditor/i/284-dep0190
Fix DEP0190 warning in generator subprocess calls
2 parents 5efa6fa + fdeccb4 commit b7bda7e

File tree

6 files changed

+31
-34
lines changed

6 files changed

+31
-34
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
type: Fix
3+
scope:
4+
- ckeditor5-package-generator
5+
closes:
6+
- 284
7+
---
8+
9+
Address the `DEP0190` deprecation warning shown during package generation by changing dependency and Git hook installation subprocess calls to avoid passing argument arrays with `shell: true`.

packages/ckeditor5-package-generator/lib/utils/install-dependencies.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,18 @@ function installPackages( directoryPath, packageManager, verbose, dev ) {
4949
}
5050

5151
if ( packageManager === 'npm' ) {
52-
const npmArguments = [
53-
'install'
54-
];
52+
let npmCommand = 'npm install';
5553

5654
// Flag required for npm 8 to install linked packages' dependencies
5755
if ( dev ) {
58-
npmArguments.push( '--install-links' );
56+
npmCommand += ' --install-links';
5957
}
6058

61-
installTask = spawn( 'npm', npmArguments, spawnOptions );
59+
installTask = spawn( npmCommand, spawnOptions );
6260
} else if ( packageManager === 'yarn' ) {
63-
installTask = spawn( 'yarnpkg', [], spawnOptions );
61+
installTask = spawn( 'yarnpkg install', spawnOptions );
6462
} else if ( packageManager === 'pnpm' ) {
65-
installTask = spawn( 'pnpm', [ 'install' ], spawnOptions );
63+
installTask = spawn( 'pnpm install', spawnOptions );
6664
} else {
6765
throw new Error( 'Unhandled package manager ' + packageManager );
6866
}

packages/ckeditor5-package-generator/lib/utils/install-git-hooks.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ export default function installGitHooks( directoryPath, logger, verbose ) {
2121
stderr: 'inherit'
2222
};
2323

24-
const spawnArguments = [ 'rebuild', 'husky' ];
25-
2624
if ( verbose ) {
2725
spawnOptions.stdio = 'inherit';
2826
}
2927

3028
// 'rebuild' was added to yarn in version 2, but we use yarn 1, thus only npm can be used.
31-
const rebuildTask = spawn( 'npm', spawnArguments, spawnOptions );
29+
const rebuildTask = spawn( 'npm rebuild husky', spawnOptions );
3230

3331
rebuildTask.on( 'close', exitCode => {
3432
if ( exitCode ) {

packages/ckeditor5-package-generator/tests/utils/install-dependencies.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ describe( 'lib/utils/install-dependencies', () => {
5757

5858
expect( spawn ).toHaveBeenCalledTimes( 1 );
5959
expect( spawn ).toHaveBeenCalledWith(
60-
'yarnpkg',
61-
[],
60+
'yarnpkg install',
6261
{
6362
encoding: 'utf8',
6463
shell: true,
@@ -73,8 +72,7 @@ describe( 'lib/utils/install-dependencies', () => {
7372

7473
expect( spawn ).toHaveBeenCalledTimes( 1 );
7574
expect( spawn ).toHaveBeenCalledWith(
76-
'yarnpkg',
77-
[],
75+
'yarnpkg install',
7876
{
7977
encoding: 'utf8',
8078
shell: true,
@@ -90,8 +88,7 @@ describe( 'lib/utils/install-dependencies', () => {
9088

9189
expect( spawn ).toHaveBeenCalledTimes( 1 );
9290
expect( spawn ).toHaveBeenCalledWith(
93-
'npm',
94-
[ 'install' ],
91+
'npm install',
9592
{
9693
encoding: 'utf8',
9794
shell: true,
@@ -106,8 +103,7 @@ describe( 'lib/utils/install-dependencies', () => {
106103

107104
expect( spawn ).toHaveBeenCalledTimes( 1 );
108105
expect( spawn ).toHaveBeenCalledWith(
109-
'npm',
110-
[ 'install' ],
106+
'npm install',
111107
{
112108
encoding: 'utf8',
113109
shell: true,
@@ -122,8 +118,7 @@ describe( 'lib/utils/install-dependencies', () => {
122118
await runTest( { packageManager: 'npm', verbose: true, dev: true } );
123119

124120
expect( spawn ).toHaveBeenCalledWith(
125-
'npm',
126-
[ 'install', '--install-links' ],
121+
'npm install --install-links',
127122
expect.any( Object )
128123
);
129124
} );
@@ -133,8 +128,7 @@ describe( 'lib/utils/install-dependencies', () => {
133128

134129
expect( spawn ).toHaveBeenCalledTimes( 1 );
135130
expect( spawn ).toHaveBeenCalledWith(
136-
'pnpm',
137-
[ 'install' ],
131+
'pnpm install',
138132
{
139133
encoding: 'utf8',
140134
shell: true,
@@ -149,8 +143,7 @@ describe( 'lib/utils/install-dependencies', () => {
149143

150144
expect( spawn ).toHaveBeenCalledTimes( 1 );
151145
expect( spawn ).toHaveBeenCalledWith(
152-
'pnpm',
153-
[ 'install' ],
146+
'pnpm install',
154147
{
155148
encoding: 'utf8',
156149
shell: true,
@@ -165,8 +158,7 @@ describe( 'lib/utils/install-dependencies', () => {
165158
await runTest( { packageManager: 'pnpm', dev: true } );
166159

167160
expect( spawn ).toHaveBeenCalledWith(
168-
'pnpm',
169-
[ 'install' ],
161+
'pnpm install',
170162
expect.any( Object )
171163
);
172164
} );

packages/ckeditor5-package-generator/tests/utils/install-git-hooks.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ describe( 'lib/utils/install-git-hooks', () => {
4343

4444
expect( spawn ).toHaveBeenCalledTimes( 1 );
4545
expect( spawn ).toHaveBeenCalledWith(
46-
'npm',
47-
[ 'rebuild', 'husky' ],
46+
'npm rebuild husky',
4847
{
4948
encoding: 'utf8',
5049
shell: true,
@@ -59,8 +58,7 @@ describe( 'lib/utils/install-git-hooks', () => {
5958

6059
expect( spawn ).toHaveBeenCalledTimes( 1 );
6160
expect( spawn ).toHaveBeenCalledWith(
62-
'npm',
63-
[ 'rebuild', 'husky' ],
61+
'npm rebuild husky',
6462
{
6563
encoding: 'utf8',
6664
shell: true,

scripts/ci/verify-build.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,11 @@ async function verifyBuild( { language, packageManager, customPluginName, instal
148148
* @returns {Object} Process
149149
*/
150150
function executeCommand( command, options ) {
151-
console.log( chalk.italic.gray( `Executing: "${ command.join( ' ' ) }".` ) );
151+
const commandString = command.join( ' ' );
152152

153-
const newProcess = spawnSync( command.shift(), command, {
153+
console.log( chalk.italic.gray( `Executing: "${ commandString }".` ) );
154+
155+
const newProcess = spawnSync( commandString, {
154156
cwd: options.cwd,
155157
encoding: 'utf8',
156158
shell: true,
@@ -176,7 +178,7 @@ function executeCommand( command, options ) {
176178
*/
177179
function startDevelopmentServer( cwd ) {
178180
return new Promise( ( resolve, reject ) => {
179-
const sampleServer = spawn( 'npm', [ 'run', 'start', '--', '--no-open' ], {
181+
const sampleServer = spawn( 'npm run start -- --no-open', {
180182
cwd,
181183
encoding: 'utf8',
182184
shell: true
@@ -227,7 +229,7 @@ function startDevelopmentServer( cwd ) {
227229
*/
228230
function startDevelopmentServerForDllBuild( cwd ) {
229231
return new Promise( ( resolve, reject ) => {
230-
const sampleServer = spawn( 'npx', [ 'http-server', './' ], {
232+
const sampleServer = spawn( 'npx http-server ./', {
231233
cwd,
232234
encoding: 'utf8',
233235
shell: true

0 commit comments

Comments
 (0)