@@ -12,7 +12,7 @@ const fixtures = require('../common/fixtures');
1212const tmpdir = require ( '../common/tmpdir' ) ;
1313const envSuffix = common . isWindows ? '-windows' : '' ;
1414
15- describe ( 'node --run [command]' , ( ) => {
15+ describe ( 'node --run [command]' , { concurrency : ! process . env . TEST_PARALLEL } , ( ) => {
1616 it ( 'returns error on non-existent file' , async ( ) => {
1717 const child = await common . spawnPromisified (
1818 process . execPath ,
@@ -286,4 +286,19 @@ describe('node --run [command]', () => {
286286 assert . strictEqual ( child . stdout , '' ) ;
287287 assert . strictEqual ( child . code , 1 ) ;
288288 } ) ;
289+
290+ it ( 'escapes shell characters' , async ( ) => {
291+ const child = await common . spawnPromisified (
292+ process . execPath ,
293+ [ '--run' , `positional-args${ envSuffix } ` , '--' , '%PAYLOAD%' , '$PAYLOAD' ] ,
294+ { cwd : fixtures . path ( 'run-script' ) , env : { ...process . env , PAYLOAD : 'env value' } } ,
295+ ) ;
296+ assert . strictEqual (
297+ child . stdout ,
298+ common . isWindows ?
299+ `Raw '"^%PAYLOAD^%" "$PAYLOAD"'\r\nArguments: '%PAYLOAD% $PAYLOAD'\r\nThe total number of arguments is: 2\r\n` :
300+ "Arguments: '%PAYLOAD% $PAYLOAD'\nThe total number of arguments is: 2\n" ) ;
301+ assert . strictEqual ( child . stderr , '' ) ;
302+ assert . strictEqual ( child . code , 0 ) ;
303+ } ) ;
289304} ) ;
0 commit comments