@@ -23,7 +23,8 @@ const npm = {
2323 flatOptions : {
2424 yes : true ,
2525 call : '' ,
26- package : [ ]
26+ package : [ ] ,
27+ legacyPeerDeps : false
2728 } ,
2829 localPrefix : 'local-prefix' ,
2930 config : {
@@ -87,6 +88,7 @@ t.afterEach(cb => {
8788 READ . length = 0
8889 READ_RESULT = ''
8990 READ_ERROR = null
91+ npm . flatOptions . legacyPeerDeps = false
9092 npm . flatOptions . package = [ ]
9193 npm . flatOptions . call = ''
9294 cb ( )
@@ -151,7 +153,7 @@ t.test('npm exec foo, not present locally or in central loc', async t => {
151153 } )
152154 t . strictSame ( MKDIRPS , [ installDir ] , 'need to make install dir' )
153155 t . match ( ARB_CTOR , [ { package : [ 'foo' ] , path } ] )
154- t . strictSame ( ARB_REIFY , [ { add : [ 'foo@' ] } ] , 'need to install foo@' )
156+ t . match ( ARB_REIFY , [ { add : [ 'foo@' ] , legacyPeerDeps : false } ] , 'need to install foo@' )
155157 t . equal ( PROGRESS_ENABLED , true , 'progress re-enabled' )
156158 const PATH = `${ resolve ( installDir , 'node_modules' , '.bin' ) } ${ delimiter } ${ process . env . PATH } `
157159 t . match ( RUN_SCRIPTS , [ {
@@ -190,7 +192,7 @@ t.test('npm exec foo, not present locally but in central loc', async t => {
190192 } )
191193 t . strictSame ( MKDIRPS , [ installDir ] , 'need to make install dir' )
192194 t . match ( ARB_CTOR , [ { package : [ 'foo' ] , path } ] )
193- t . strictSame ( ARB_REIFY , [ ] , 'no need to install again, already there' )
195+ t . match ( ARB_REIFY , [ ] , 'no need to install again, already there' )
194196 t . equal ( PROGRESS_ENABLED , true , 'progress re-enabled' )
195197 const PATH = `${ resolve ( installDir , 'node_modules' , '.bin' ) } ${ delimiter } ${ process . env . PATH } `
196198 t . match ( RUN_SCRIPTS , [ {
@@ -229,7 +231,7 @@ t.test('npm exec foo, present locally but wrong version', async t => {
229231 } )
230232 t . strictSame ( MKDIRPS , [ installDir ] , 'need to make install dir' )
231233 t . match ( ARB_CTOR , [ { package : [ 'foo' ] , path } ] )
232- t . strictSame ( ARB_REIFY , [ { add :
[ '[email protected] ' ] } ] , 'need to add [email protected] ' ) 234+ t . match ( ARB_REIFY , [ { add :
[ '[email protected] ' ] , legacyPeerDeps : false } ] , 'need to add [email protected] ' ) 233235 t . equal ( PROGRESS_ENABLED , true , 'progress re-enabled' )
234236 const PATH = `${ resolve ( installDir , 'node_modules' , '.bin' ) } ${ delimiter } ${ process . env . PATH } `
235237 t . match ( RUN_SCRIPTS , [ {
@@ -360,7 +362,7 @@ t.test('run command with 2 packages, need install, verify sort', t => {
360362 } )
361363 t . strictSame ( MKDIRPS , [ installDir ] , 'need to make install dir' )
362364 t . match ( ARB_CTOR , [ { package : packages , path } ] )
363- t . strictSame ( ARB_REIFY , [ { add} ] , 'need to install both packages' )
365+ t . match ( ARB_REIFY , [ { add, legacyPeerDeps : false } ] , 'need to install both packages' )
364366 t . equal ( PROGRESS_ENABLED , true , 'progress re-enabled' )
365367 const PATH = `${ resolve ( installDir , 'node_modules' , '.bin' ) } ${ delimiter } ${ process . env . PATH } `
366368 t . match ( RUN_SCRIPTS , [ {
@@ -502,7 +504,7 @@ t.test('prompt when installs are needed if not already present', async t => {
502504 } )
503505 t . strictSame ( MKDIRPS , [ installDir ] , 'need to make install dir' )
504506 t . match ( ARB_CTOR , [ { package : packages , path } ] )
505- t . strictSame ( ARB_REIFY , [ { add} ] , 'need to install both packages' )
507+ t . match ( ARB_REIFY , [ { add, legacyPeerDeps : false } ] , 'need to install both packages' )
506508 t . equal ( PROGRESS_ENABLED , true , 'progress re-enabled' )
507509 const PATH = `${ resolve ( installDir , 'node_modules' , '.bin' ) } ${ delimiter } ${ process . env . PATH } `
508510 t . match ( RUN_SCRIPTS , [ {
@@ -656,3 +658,31 @@ t.test('abort if -n provided', async t => {
656658 t . strictSame ( RUN_SCRIPTS , [ ] )
657659 t . strictSame ( READ , [ ] )
658660} )
661+
662+ t . test ( 'forward legacyPeerDeps opt' , async t => {
663+ const path = t . testdir ( )
664+ const installDir = resolve ( 'cache-dir/_npx/f7fbba6e0636f890' )
665+ npm . localPrefix = path
666+ ARB_ACTUAL_TREE [ path ] = {
667+ children : new Map ( )
668+ }
669+ ARB_ACTUAL_TREE [ installDir ] = {
670+ children : new Map ( )
671+ }
672+ MANIFESTS . foo = {
673+ name : 'foo' ,
674+ version : '1.2.3' ,
675+ bin : {
676+ foo : 'foo'
677+ } ,
678+ _from : 'foo@'
679+ }
680+ npm . flatOptions . yes = true
681+ npm . flatOptions . legacyPeerDeps = true
682+ await exec ( [ 'foo' ] , er => {
683+ if ( er ) {
684+ throw er
685+ }
686+ } )
687+ t . match ( ARB_REIFY , [ { add : [ 'foo@' ] , legacyPeerDeps : true } ] , 'need to install foo@ using legacyPeerDeps opt' )
688+ } )
0 commit comments