File tree 2 files changed +40
-4
lines changed
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 {
82
82
}
83
83
}
84
84
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 ) {
89
88
this . npm . output ( JSON . stringify ( result , null , 2 ) )
90
89
}
91
90
Original file line number Diff line number Diff line change @@ -618,6 +618,43 @@ t.test('workspaces', async t => {
618
618
)
619
619
} )
620
620
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
+
621
658
t . test ( 'fix' , async t => {
622
659
const { pkg, readPackageJson } = await mockNpm ( t , {
623
660
prefixDir : {
You can’t perform that action at this time.
0 commit comments