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 | |
parent | d8dcc02cfd354c1314c45d6530ec926cd138210c (diff) |
fix: consolidate is-windows code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/commands/completion.js | 2 | ||||
-rw-r--r-- | lib/commands/run-script.js | 2 | ||||
-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 |
8 files changed, 11 insertions, 11 deletions
diff --git a/lib/commands/completion.js b/lib/commands/completion.js index 22f91b0ae..d0c68af6c 100644 --- a/lib/commands/completion.js +++ b/lib/commands/completion.js @@ -37,7 +37,7 @@ const nopt = require('nopt') const configNames = Object.keys(definitions) const shorthandNames = Object.keys(shorthands) const allConfs = configNames.concat(shorthandNames) -const isWindowsShell = require('../utils/is-windows-shell.js') +const { isWindowsShell } = require('../utils/is-windows.js') const fileExists = require('../utils/file-exists.js') const { promisify } = require('util') diff --git a/lib/commands/run-script.js b/lib/commands/run-script.js index e31172cc8..a1591c790 100644 --- a/lib/commands/run-script.js +++ b/lib/commands/run-script.js @@ -5,7 +5,7 @@ const { isServerPackage } = runScript const rpj = require('read-package-json-fast') const log = require('../utils/log-shim.js') const didYouMean = require('../utils/did-you-mean.js') -const isWindowsShell = require('../utils/is-windows-shell.js') +const { isWindowsShell } = require('../utils/is-windows.js') const cmdList = [ 'publish', 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) |