From 46e14bd0ff566f94e8f86f9d972bf089c000da52 Mon Sep 17 00:00:00 2001 From: Gar Date: Mon, 8 Mar 2021 16:22:54 -0800 Subject: 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 --- lib/utils/ping.js | 4 ++-- lib/utils/read-local-package.js | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/utils') 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 -- cgit v1.2.3