Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorGar <gar+gh@danger.computer>2021-03-09 03:22:54 +0300
committerisaacs <i@izs.me>2021-03-18 21:54:42 +0300
commit46e14bd0ff566f94e8f86f9d972bf089c000da52 (patch)
treee6b478f20fd306f149e508fdacc373f7f1bba124 /lib/utils
parentb395763f002457866d8bf4bf37858f69459f1d30 (diff)
chore(config): remove flatOptions references
Iterative change moving us towards a more unified config. No longer pulling config from flatOptions where we don't have to. PR-URL: https://github.com/npm/cli/pull/2892 Credit: @wraithgar Close: #2892 Reviewed-by: @ruyadorno
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/ping.js4
-rw-r--r--lib/utils/read-local-package.js7
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/utils/ping.js b/lib/utils/ping.js
index f5f7fcc6a..00956d0c1 100644
--- a/lib/utils/ping.js
+++ b/lib/utils/ping.js
@@ -1,7 +1,7 @@
// ping the npm registry
// used by the ping and doctor commands
const fetch = require('npm-registry-fetch')
-module.exports = async (opts) => {
- const res = await fetch('/-/ping?write=true', opts)
+module.exports = async (flatOptions) => {
+ const res = await fetch('/-/ping?write=true', flatOptions)
return res.json().catch(() => ({}))
}
diff --git a/lib/utils/read-local-package.js b/lib/utils/read-local-package.js
index c31bca994..21506ca18 100644
--- a/lib/utils/read-local-package.js
+++ b/lib/utils/read-local-package.js
@@ -1,11 +1,12 @@
const { resolve } = require('path')
const readJson = require('read-package-json-fast')
async function readLocalPackageName (npm) {
- if (npm.flatOptions.global)
+ if (npm.config.get('global'))
return
- const filepath = resolve(npm.flatOptions.prefix, 'package.json')
- return (await readJson(filepath)).name
+ const filepath = resolve(npm.prefix, 'package.json')
+ const json = await readJson(filepath)
+ return json.name
}
module.exports = readLocalPackageName