File tree Expand file tree Collapse file tree
tap-snapshots/test/lib/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ class LS extends ArboristWorkspaceCmd {
9292 }
9393
9494 if ( this . npm . flatOptions . includeWorkspaceRoot
95- && ! edge . to . isWorkspace ) {
95+ && edge . to && ! edge . to . isWorkspace ) {
9696 return true
9797 }
9898
Original file line number Diff line number Diff line change @@ -678,6 +678,13 @@ dedupe-entries@1.0.0 {CWD}/tap-testdir-ls-ls-with-no-args-dedupe-entries-and-not
678678
679679`
680680
681+ exports [ `test/lib/commands/ls.js TAP ls workspace and missing optional dep > should omit missing optional dep 1` ] = `
682+ root@ {CWD}/tap-testdir-ls-ls-workspace-and-missing-optional-dep
683+ +-- baz@1.0.0 -> ./baz
684+ \`-- foo@1.0.0
685+
686+ `
687+
681688exports [ `test/lib/commands/ls.js TAP show multiple invalid reasons > ls result 1` ] = `
682689test-npm-ls@1.0.0 {cwd}/tap-testdir-ls-show-multiple-invalid-reasons
683690+-- cat@1.0.0 invalid: "^2.0.0" from the root project
Original file line number Diff line number Diff line change @@ -178,6 +178,44 @@ t.test('ls', t => {
178178 )
179179 } )
180180
181+ t . test ( 'workspace and missing optional dep' , async t => {
182+ npm . prefix = npm . localPrefix = t . testdir ( {
183+ 'package.json' : JSON . stringify ( {
184+ name : 'root' ,
185+ dependencies : {
186+ foo : '^1.0.0' ,
187+ } ,
188+ optionalDependencies : {
189+ bar : '^1.0.0' ,
190+ } ,
191+ workspaces : [ './baz' ] ,
192+ } ) ,
193+ baz : {
194+ 'package.json' : JSON . stringify ( {
195+ name : 'baz' ,
196+ version : '1.0.0' ,
197+ } ) ,
198+ } ,
199+ node_modules : {
200+ baz : t . fixture ( 'symlink' , '../baz' ) ,
201+ foo : {
202+ 'package.json' : JSON . stringify ( {
203+ name : 'foo' ,
204+ version : '1.0.0' ,
205+ } ) ,
206+ } ,
207+ } ,
208+ } )
209+
210+ npm . flatOptions . includeWorkspaceRoot = true
211+ t . teardown ( ( ) => {
212+ delete npm . flatOptions . includeWorkspaceRoot
213+ } )
214+
215+ await ls . execWorkspaces ( [ ] , [ 'baz' ] )
216+ t . matchSnapshot ( redactCwd ( result ) , 'should omit missing optional dep' )
217+ } )
218+
181219 t . test ( 'extraneous deps' , async t => {
182220 npm . prefix = t . testdir ( {
183221 'package.json' : JSON . stringify ( {
You can’t perform that action at this time.
0 commit comments