@@ -304,13 +304,54 @@ describe('doctor', function () {
304
304
pkgUpgraded . should . containIgnoreCase ( '"ncu-test-v2": "~2.0.0"' )
305
305
} )
306
306
307
+ it ( 'custom test script with --doctorTest command that includes spaced words wrapped in quotes' , async function ( ) {
308
+ // use dynamic import for ESM module
309
+ const { default : stripAnsi } = await import ( 'strip-ansi' )
310
+ const cwd = path . join ( doctorTests , 'customtest2' )
311
+ const pkgPath = path . join ( cwd , 'package.json' )
312
+ const lockfilePath = path . join ( cwd , 'package-lock.json' )
313
+ const nodeModulesPath = path . join ( cwd , 'node_modules' )
314
+ const echoPath = path . join ( cwd , 'echo.js' )
315
+ const pkgOriginal = await fs . readFile ( path . join ( cwd , 'package.json' ) , 'utf-8' )
316
+ let stdout = ''
317
+ let stderr = ''
318
+
319
+ try {
320
+ await ncu ( [ '--doctor' , '-u' , '--doctorTest' , `node ${ echoPath } '123 456'` ] , {
321
+ cwd,
322
+ stdout : function ( data : string ) {
323
+ stdout += data
324
+ } ,
325
+ stderr : function ( data : string ) {
326
+ stderr += data
327
+ } ,
328
+ } )
329
+ } catch ( e ) { }
330
+
331
+ const pkgUpgraded = await fs . readFile ( pkgPath , 'utf-8' )
332
+
333
+ // cleanup before assertions in case they fail
334
+ await fs . writeFile ( pkgPath , pkgOriginal )
335
+ rimraf . sync ( lockfilePath )
336
+ rimraf . sync ( nodeModulesPath )
337
+
338
+ // stderr should be empty
339
+ stderr . should . equal ( '' )
340
+
341
+ // stdout should include expected output
342
+ stripAnsi ( stdout ) . should . contain ( "'123 456'" )
343
+
344
+ // package file should include upgrades
345
+ pkgUpgraded . should . containIgnoreCase ( '"ncu-test-v2": "~2.0.0"' )
346
+ } )
347
+
307
348
it ( 'handle failed prepare script' , async ( ) => {
308
349
const tempDir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'npm-check-updates-' ) )
309
350
const pkgPath = path . join ( tempDir , 'package.json' )
310
351
await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'npm-check-updates-' ) )
311
352
312
353
/*
313
- - packagu .json
354
+ - package .json
314
355
- tsconfig.json
315
356
- src/
316
357
- index.ts
0 commit comments