File tree 3 files changed +52
-1
lines changed
tap-snapshots/test/lib/commands
3 files changed +52
-1
lines changed Original file line number Diff line number Diff line change @@ -46,7 +46,12 @@ class Publish extends BaseCommand {
46
46
await this . #publish( args )
47
47
}
48
48
49
- async execWorkspaces ( ) {
49
+ async execWorkspaces ( args ) {
50
+ const useWorkspaces = args . length === 0 || args . includes ( '.' )
51
+ if ( ! useWorkspaces ) {
52
+ log . warn ( 'Ignoring workspaces for specified package(s)' )
53
+ return this . exec ( args )
54
+ }
50
55
await this . setWorkspaces ( )
51
56
52
57
for ( const [ name , workspace ] of this . workspaces . entries ( ) ) {
Original file line number Diff line number Diff line change @@ -393,6 +393,10 @@ exports[`test/lib/commands/publish.js TAP workspaces all workspaces - some marke
393
393
+ workspace-a@1.2.3-a
394
394
`
395
395
396
+ exports [ `test/lib/commands/publish.js TAP workspaces differet package spec > publish different package spec 1` ] = `
397
+ + pkg@1.2.3
398
+ `
399
+
396
400
exports [ `test/lib/commands/publish.js TAP workspaces json > all workspaces in json 1` ] = `
397
401
{
398
402
"workspace-a": {
Original file line number Diff line number Diff line change @@ -700,6 +700,48 @@ t.test('workspaces', t => {
700
700
await npm . exec ( 'publish' , [ ] )
701
701
t . matchSnapshot ( joinedOutput ( ) , 'all workspaces in json' )
702
702
} )
703
+
704
+ t . test ( 'differet package spec' , async t => {
705
+ const testDir = {
706
+ 'package.json' : JSON . stringify (
707
+ {
708
+ ...pkgJson ,
709
+ workspaces : [ 'workspace-a' ] ,
710
+ } , null , 2 ) ,
711
+ 'workspace-a' : {
712
+ 'package.json' : JSON . stringify ( {
713
+ name : 'workspace-a' ,
714
+ version : '1.2.3-a' ,
715
+ } ) ,
716
+ } ,
717
+ 'dir/pkg' : {
718
+ 'package.json' : JSON . stringify ( {
719
+ name : 'pkg' ,
720
+ version : '1.2.3' ,
721
+ } ) ,
722
+ } ,
723
+ }
724
+
725
+ const { npm, joinedOutput } = await loadMockNpm ( t , {
726
+ config : {
727
+ ...auth ,
728
+ } ,
729
+ prefixDir : testDir ,
730
+ chdir : ( { prefix } ) => path . resolve ( prefix , './workspace-a' ) ,
731
+ } )
732
+ const registry = new MockRegistry ( {
733
+ tap : t ,
734
+ registry : npm . config . get ( 'registry' ) ,
735
+ authorization : token ,
736
+ } )
737
+ registry . nock
738
+ . put ( '/pkg' , body => {
739
+ return t . match ( body , { name : 'pkg' } )
740
+ } ) . reply ( 200 , { } )
741
+ await npm . exec ( 'publish' , [ '../dir/pkg' ] )
742
+ t . matchSnapshot ( joinedOutput ( ) , 'publish different package spec' )
743
+ } )
744
+
703
745
t . end ( )
704
746
} )
705
747
You can’t perform that action at this time.
0 commit comments