File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -109,13 +109,13 @@ class Link extends ArboristWorkspaceCmd {
109109 // using any of --save-dev or other types
110110 const save =
111111 Boolean (
112- this . npm . config . find ( 'save' ) !== 'default' ||
112+ ( this . npm . config . find ( 'save' ) !== 'default' &&
113+ this . npm . config . get ( 'save' ) ) ||
113114 this . npm . config . get ( 'save-optional' ) ||
114115 this . npm . config . get ( 'save-peer' ) ||
115116 this . npm . config . get ( 'save-dev' ) ||
116117 this . npm . config . get ( 'save-prod' )
117118 )
118-
119119 // create a new arborist instance for the local prefix and
120120 // reify all the pending names as symlinks there
121121 const localArb = new Arborist ( {
Original file line number Diff line number Diff line change @@ -369,6 +369,40 @@ t.test('link pkg already in global space when prefix is a symlink', async t => {
369369 t . matchSnapshot ( await printLinks ( ) , 'should create a local symlink to global pkg' )
370370} )
371371
372+ t . test ( 'should not save link to package file' , async t => {
373+ const { link, prefix } = await mockLink ( t , {
374+ globalPrefixDir : {
375+ node_modules : {
376+ '@myscope' : {
377+ linked : t . fixture ( 'symlink' , '../../../other/scoped-linked' ) ,
378+ } ,
379+ } ,
380+ } ,
381+ otherDirs : {
382+ 'scoped-linked' : {
383+ 'package.json' : JSON . stringify ( {
384+ name : '@myscope/linked' ,
385+ version : '1.0.0' ,
386+ } ) ,
387+ } ,
388+ } ,
389+ prefixDir : {
390+ 'package.json' : JSON . stringify ( {
391+ name : 'my-project' ,
392+ version : '1.0.0' ,
393+ } ) ,
394+ } ,
395+ config : { save : false } ,
396+ } )
397+
398+ await link . exec ( [ '@myscope/linked' ] )
399+ t . match (
400+ require ( resolve ( prefix , 'package.json' ) ) . dependencies ,
401+ undefined ,
402+ 'should not save to package.json upon linking'
403+ )
404+ } )
405+
372406t . test ( 'should not prune dependencies when linking packages' , async t => {
373407 const { link, prefix } = await mockLink ( t , {
374408 globalPrefixDir : {
You can’t perform that action at this time.
0 commit comments