@@ -1137,6 +1137,46 @@ t.test('workspaces', async (t) => {
11371137 t . equal ( logs . length , 0 , 'got no log messages' )
11381138 } )
11391139
1140+ t . test ( 'global skips auto detect' , async ( t ) => {
1141+ const cwd = process . cwd ( )
1142+ t . teardown ( ( ) => process . chdir ( cwd ) )
1143+ process . chdir ( `${ path } /workspaces/one` )
1144+
1145+ const config = new Config ( {
1146+ npmPath : process . cwd ( ) ,
1147+ env : { } ,
1148+ argv : [ process . execPath , __filename , '--global' ] ,
1149+ cwd : `${ path } /workspaces/one` ,
1150+ shorthands,
1151+ definitions,
1152+ } )
1153+
1154+ await config . load ( )
1155+ t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1156+ t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1157+ t . equal ( logs . length , 0 , 'got no log messages' )
1158+ } )
1159+
1160+ t . test ( 'location=global skips auto detect' , async ( t ) => {
1161+ const cwd = process . cwd ( )
1162+ t . teardown ( ( ) => process . chdir ( cwd ) )
1163+ process . chdir ( `${ path } /workspaces/one` )
1164+
1165+ const config = new Config ( {
1166+ npmPath : process . cwd ( ) ,
1167+ env : { } ,
1168+ argv : [ process . execPath , __filename , '--location=global' ] ,
1169+ cwd : `${ path } /workspaces/one` ,
1170+ shorthands,
1171+ definitions,
1172+ } )
1173+
1174+ await config . load ( )
1175+ t . equal ( config . localPrefix , join ( path , 'workspaces' , 'one' ) , 'localPrefix is the root' )
1176+ t . same ( config . get ( 'workspace' ) , [ ] , 'did not set workspace' )
1177+ t . equal ( logs . length , 0 , 'got no log messages' )
1178+ } )
1179+
11401180 t . test ( 'does not error for invalid package.json' , async ( t ) => {
11411181 const invalidPkg = join ( path , 'workspaces' , 'package.json' )
11421182 const cwd = process . cwd ( )
0 commit comments