diff options
author | Gar <gar+gh@danger.computer> | 2022-03-24 19:09:26 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-28 23:21:36 +0300 |
commit | 0a957f5e2fbcce51c407d22b19e38004d09c51af (patch) | |
tree | d69aad0531c04ecd010f3b245b102a0e5a288df2 /lib | |
parent | 57d8f75eb864486f6aa17bb3dd2f213b5c148073 (diff) |
fix: consolidate path delimiter logic
Diffstat (limited to 'lib')
-rw-r--r-- | lib/commands/bin.js | 8 | ||||
-rw-r--r-- | lib/utils/path.js | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/lib/commands/bin.js b/lib/commands/bin.js index 07d33167d..4200d5b8c 100644 --- a/lib/commands/bin.js +++ b/lib/commands/bin.js @@ -1,6 +1,10 @@ const log = require('../utils/log-shim.js') -const envPath = require('../utils/path.js') const BaseCommand = require('../base-command.js') +// TODO this may not be needed at all. Ignoring because our tests normalize +// process.env.path already +/* istanbul ignore next */ +const path = process.env.path || process.env.Path || process.env.PATH +const { delimiter } = require('path') class Bin extends BaseCommand { static description = 'Display npm bin folder' @@ -11,7 +15,7 @@ class Bin extends BaseCommand { async exec (args) { const b = this.npm.bin this.npm.output(b) - if (this.npm.config.get('global') && !envPath.includes(b)) { + if (this.npm.config.get('global') && !path.split(delimiter).includes(b)) { log.error('bin', '(not in PATH env variable)') } } diff --git a/lib/utils/path.js b/lib/utils/path.js deleted file mode 100644 index fcbf92e56..000000000 --- a/lib/utils/path.js +++ /dev/null @@ -1,5 +0,0 @@ -// 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) |