@@ -129,7 +129,6 @@ class Npm extends EventEmitter {
129
129
} )
130
130
}
131
131
132
- const isGlobal = this . config . get ( 'global' )
133
132
const workspacesEnabled = this . config . get ( 'workspaces' )
134
133
// if cwd is a workspace, the default is set to [that workspace]
135
134
const implicitWorkspace = this . config . get ( 'workspace' , 'default' ) . length > 0
@@ -160,7 +159,7 @@ class Npm extends EventEmitter {
160
159
execPromise = Promise . reject (
161
160
new Error ( 'Can not use --no-workspaces and --workspace at the same time' ) )
162
161
} else if ( filterByWorkspaces ) {
163
- if ( isGlobal ) {
162
+ if ( this . global ) {
164
163
execPromise = Promise . reject ( new Error ( 'Workspaces not supported for global packages' ) )
165
164
} else {
166
165
execPromise = command . execWorkspaces ( args , workspacesFilters )
@@ -333,6 +332,10 @@ class Npm extends EventEmitter {
333
332
return this . #chalk
334
333
}
335
334
335
+ get global ( ) {
336
+ return this . config . get ( 'global' ) || this . config . get ( 'location' ) === 'global'
337
+ }
338
+
336
339
get logColor ( ) {
337
340
return this . flatOptions . logColor
338
341
}
@@ -409,7 +412,7 @@ class Npm extends EventEmitter {
409
412
}
410
413
411
414
get dir ( ) {
412
- return this . config . get ( ' global' ) ? this . globalDir : this . localDir
415
+ return this . global ? this . globalDir : this . localDir
413
416
}
414
417
415
418
get globalBin ( ) {
@@ -422,15 +425,15 @@ class Npm extends EventEmitter {
422
425
}
423
426
424
427
get bin ( ) {
425
- return this . config . get ( ' global' ) ? this . globalBin : this . localBin
428
+ return this . global ? this . globalBin : this . localBin
426
429
}
427
430
428
431
get prefix ( ) {
429
- return this . config . get ( ' global' ) ? this . globalPrefix : this . localPrefix
432
+ return this . global ? this . globalPrefix : this . localPrefix
430
433
}
431
434
432
435
set prefix ( r ) {
433
- const k = this . config . get ( ' global' ) ? 'globalPrefix' : 'localPrefix'
436
+ const k = this . global ? 'globalPrefix' : 'localPrefix'
434
437
this [ k ] = r
435
438
}
436
439
0 commit comments