diff options
author | Gar <gar+gh@danger.computer> | 2022-03-24 17:44:01 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-28 23:21:36 +0300 |
commit | f76d4f2f661bcc2534f541ee0e7d683155372baf (patch) | |
tree | b4edbfc7306780aac35f7aa727f604944a8cc4c4 /lib/utils | |
parent | d8dcc02cfd354c1314c45d6530ec926cd138210c (diff) |
fix: consolidate is-windows code
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/config/definitions.js | 2 | ||||
-rw-r--r-- | lib/utils/error-message.js | 2 | ||||
-rw-r--r-- | lib/utils/is-windows-bash.js | 3 | ||||
-rw-r--r-- | lib/utils/is-windows-shell.js | 3 | ||||
-rw-r--r-- | lib/utils/is-windows.js | 7 | ||||
-rw-r--r-- | lib/utils/path.js | 1 |
6 files changed, 9 insertions, 9 deletions
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) |