From f76d4f2f661bcc2534f541ee0e7d683155372baf Mon Sep 17 00:00:00 2001 From: Gar Date: Thu, 24 Mar 2022 07:44:01 -0700 Subject: fix: consolidate is-windows code --- lib/utils/config/definitions.js | 2 +- lib/utils/error-message.js | 2 +- lib/utils/is-windows-bash.js | 3 --- lib/utils/is-windows-shell.js | 3 --- lib/utils/is-windows.js | 7 ++++++- lib/utils/path.js | 1 + 6 files changed, 9 insertions(+), 9 deletions(-) delete mode 100644 lib/utils/is-windows-bash.js delete mode 100644 lib/utils/is-windows-shell.js (limited to 'lib/utils') diff --git a/lib/utils/config/definitions.js b/lib/utils/config/definitions.js index 04da7f607..efc1f72a0 100644 --- a/lib/utils/config/definitions.js +++ b/lib/utils/config/definitions.js @@ -7,7 +7,7 @@ const { version: npmVersion } = require('../../../package.json') const ciDetect = require('@npmcli/ci-detect') const ciName = ciDetect() const querystring = require('querystring') -const isWindows = require('../is-windows.js') +const { isWindows } = require('../is-windows.js') const { join } = require('path') // used by cafile flattening to flatOptions.ca diff --git a/lib/utils/error-message.js b/lib/utils/error-message.js index 5fa361efc..adf10a56f 100644 --- a/lib/utils/error-message.js +++ b/lib/utils/error-message.js @@ -60,7 +60,7 @@ module.exports = (er, npm) => { npm.config.loaded && er.dest.startsWith(npm.config.get('cache')) - const isWindows = require('./is-windows.js') + const { isWindows } = require('./is-windows.js') if (!isWindows && (isCachePath || isCacheDest)) { // user probably doesn't need this, but still add it to the debug log diff --git a/lib/utils/is-windows-bash.js b/lib/utils/is-windows-bash.js deleted file mode 100644 index 0ae99e212..000000000 --- a/lib/utils/is-windows-bash.js +++ /dev/null @@ -1,3 +0,0 @@ -const isWindows = require('./is-windows.js') -module.exports = isWindows && - (/^MINGW(32|64)$/.test(process.env.MSYSTEM) || process.env.TERM === 'cygwin') diff --git a/lib/utils/is-windows-shell.js b/lib/utils/is-windows-shell.js deleted file mode 100644 index 477bd43cc..000000000 --- a/lib/utils/is-windows-shell.js +++ /dev/null @@ -1,3 +0,0 @@ -const isWindows = require('./is-windows.js') -const isWindowsBash = require('./is-windows-bash.js') -module.exports = isWindows && !isWindowsBash diff --git a/lib/utils/is-windows.js b/lib/utils/is-windows.js index fbece90ad..57f6599b6 100644 --- a/lib/utils/is-windows.js +++ b/lib/utils/is-windows.js @@ -1 +1,6 @@ -module.exports = process.platform === 'win32' +const isWindows = process.platform === 'win32' +const isWindowsShell = isWindows && + !/^MINGW(32|64)$/.test(process.env.MSYSTEM) && process.env.TERM !== 'cygwin' + +exports.isWindows = isWindows +exports.isWindowsShell = isWindowsShell diff --git a/lib/utils/path.js b/lib/utils/path.js index ad0065a2c..fcbf92e56 100644 --- a/lib/utils/path.js +++ b/lib/utils/path.js @@ -1,4 +1,5 @@ // return the PATH array in a cross-platform way +// TODO this is only used in a single place const PATH = process.env.PATH || process.env.Path || process.env.path const { delimiter } = require('path') module.exports = PATH.split(delimiter) -- cgit v1.2.3