Skip to content

Commit 0f89e07

Browse files
authored
fix: add global getter to npm class (#4935)
1 parent 357b0af commit 0f89e07

File tree

21 files changed

+44
-32
lines changed

21 files changed

+44
-32
lines changed

lib/commands/bin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Bin extends BaseCommand {
1515
async exec (args) {
1616
const b = this.npm.bin
1717
this.npm.output(b)
18-
if (this.npm.config.get('global') && !path.split(delimiter).includes(b)) {
18+
if (this.npm.global && !path.split(delimiter).includes(b)) {
1919
log.error('bin', '(not in PATH env variable)')
2020
}
2121
}

lib/commands/ci.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class CI extends ArboristWorkspaceCmd {
2121
]
2222

2323
async exec () {
24-
if (this.npm.config.get('global')) {
24+
if (this.npm.global) {
2525
throw Object.assign(new Error('`npm ci` does not work for global packages'), {
2626
code: 'ECIGLOBAL',
2727
})

lib/commands/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ ${defData}
276276
msg.push('')
277277
}
278278

279-
if (!this.npm.config.get('global')) {
279+
if (!this.npm.global) {
280280
const pkgPath = resolve(this.npm.prefix, 'package.json')
281281
const pkg = await rpj(pkgPath).catch(() => ({}))
282282

lib/commands/dedupe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Dedupe extends ArboristWorkspaceCmd {
2222
]
2323

2424
async exec (args) {
25-
if (this.npm.config.get('global')) {
25+
if (this.npm.global) {
2626
const er = new Error('`npm dedupe` does not work in global mode.')
2727
er.code = 'EDEDUPEGLOBAL'
2828
throw er

lib/commands/diff.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Diff extends BaseCommand {
5050
// node_modules is sometimes under ./lib, and in global mode we're only ever
5151
// walking through node_modules (because we will have been given a package
5252
// name already)
53-
if (this.npm.config.get('global')) {
53+
if (this.npm.global) {
5454
this.top = resolve(this.npm.globalDir, '..')
5555
} else {
5656
this.top = this.prefix

lib/commands/dist-tag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class DistTag extends BaseCommand {
148148

149149
async list (spec, opts) {
150150
if (!spec) {
151-
if (this.npm.config.get('global')) {
151+
if (this.npm.global) {
152152
throw this.usageError()
153153
}
154154
const { name } = await readPackage(path.resolve(this.npm.prefix, 'package.json'))

lib/commands/fund.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Fund extends ArboristWorkspaceCmd {
4545
throw err
4646
}
4747

48-
if (this.npm.config.get('global')) {
48+
if (this.npm.global) {
4949
const err = new Error('`npm fund` does not support global packages')
5050
err.code = 'EFUNDGLOBAL'
5151
throw err

lib/commands/install.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Install extends ArboristWorkspaceCmd {
106106
// the /path/to/node_modules/..
107107
const globalTop = resolve(this.npm.globalDir, '..')
108108
const ignoreScripts = this.npm.config.get('ignore-scripts')
109-
const isGlobalInstall = this.npm.config.get('global')
109+
const isGlobalInstall = this.npm.global
110110
const where = isGlobalInstall ? globalTop : this.npm.prefix
111111
const forced = this.npm.config.get('force')
112112
const scriptShell = this.npm.config.get('script-shell') || undefined

lib/commands/link.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Link extends ArboristWorkspaceCmd {
4343
}
4444

4545
async exec (args) {
46-
if (this.npm.config.get('global')) {
46+
if (this.npm.global) {
4747
throw Object.assign(
4848
new Error(
4949
'link should never be --global.\n' +

lib/commands/ls.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LS extends ArboristWorkspaceCmd {
5252
const all = this.npm.config.get('all')
5353
const color = this.npm.color
5454
const depth = this.npm.config.get('depth')
55-
const global = this.npm.config.get('global')
55+
const global = this.npm.global
5656
const json = this.npm.config.get('json')
5757
const link = this.npm.config.get('link')
5858
const long = this.npm.config.get('long')

0 commit comments

Comments
 (0)