File tree Expand file tree Collapse file tree 2 files changed +40
-4
lines changed
Expand file tree Collapse file tree 2 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,9 @@ class Pkg extends BaseCommand {
8282 }
8383 }
8484
85- // only outputs if not running with workspaces config,
86- // in case you're retrieving info for workspaces the pkgWorkspaces
87- // will handle the output to make sure it get keyed by ws name
88- if ( ! this . npm . config . get ( 'workspaces' ) ) {
85+ // only outputs if not running with workspaces config
86+ // execWorkspaces will handle the output otherwise
87+ if ( ! this . workspaces ) {
8988 this . npm . output ( JSON . stringify ( result , null , 2 ) )
9089 }
9190
Original file line number Diff line number Diff line change @@ -662,6 +662,43 @@ t.test('workspaces', async t => {
662662 )
663663} )
664664
665+ t . test ( 'single workspace' , async t => {
666+ const { pkg, OUTPUT } = await mockNpm ( t , {
667+ prefixDir : {
668+ 'package.json' : JSON . stringify ( {
669+ name : 'root' ,
670+ version : '1.0.0' ,
671+ workspaces : [
672+ 'packages/*' ,
673+ ] ,
674+ } ) ,
675+ packages : {
676+ a : {
677+ 'package.json' : JSON . stringify ( {
678+ name : 'a' ,
679+ version : '1.0.0' ,
680+ } ) ,
681+ } ,
682+ b : {
683+ 'package.json' : JSON . stringify ( {
684+ name : 'b' ,
685+ version : '1.2.3' ,
686+ } ) ,
687+ } ,
688+ } ,
689+ } ,
690+ config : { workspace : [ 'packages/a' ] } ,
691+ } )
692+
693+ await pkg ( 'get' , 'name' , 'version' )
694+
695+ t . strictSame (
696+ JSON . parse ( OUTPUT ( ) ) ,
697+ { a : { name : 'a' , version : '1.0.0' } } ,
698+ 'should only return info for one workspace'
699+ )
700+ } )
701+
665702t . test ( 'fix' , async t => {
666703 const { pkg, readPackageJson } = await mockNpm ( t , {
667704 prefixDir : {
You can’t perform that action at this time.
0 commit comments