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 @@ -618,6 +618,43 @@ t.test('workspaces', async t => {
618618 )
619619} )
620620
621+ t . test ( 'single workspace' , async t => {
622+ const { pkg, OUTPUT } = await mockNpm ( t , {
623+ prefixDir : {
624+ 'package.json' : JSON . stringify ( {
625+ name : 'root' ,
626+ version : '1.0.0' ,
627+ workspaces : [
628+ 'packages/*' ,
629+ ] ,
630+ } ) ,
631+ packages : {
632+ a : {
633+ 'package.json' : JSON . stringify ( {
634+ name : 'a' ,
635+ version : '1.0.0' ,
636+ } ) ,
637+ } ,
638+ b : {
639+ 'package.json' : JSON . stringify ( {
640+ name : 'b' ,
641+ version : '1.2.3' ,
642+ } ) ,
643+ } ,
644+ } ,
645+ } ,
646+ config : { workspace : [ 'packages/a' ] } ,
647+ } )
648+
649+ await pkg ( 'get' , 'name' , 'version' )
650+
651+ t . strictSame (
652+ JSON . parse ( OUTPUT ( ) ) ,
653+ { a : { name : 'a' , version : '1.0.0' } } ,
654+ 'should only return info for one workspace'
655+ )
656+ } )
657+
621658t . test ( 'fix' , async t => {
622659 const { pkg, readPackageJson } = await mockNpm ( t , {
623660 prefixDir : {
You can’t perform that action at this time.
0 commit comments