From 37d0b8458e403767303d8f411aad113d8d63741a Mon Sep 17 00:00:00 2001 From: Eli Doran Date: Thu, 17 Jan 2019 18:17:47 -0500 Subject: [PATCH] Reduce work to test if executable ends with a 'g'. Avoid: * declaring path var * requiring path module * calling path.basename() * calling slice() to get one letter from the string Instead: * refer to it from the argv array * refer to it as one less than the executable paths length --- bin/npm-cli.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/npm-cli.js b/bin/npm-cli.js index 6f76b23828531..705aa472e7e55 100755 --- a/bin/npm-cli.js +++ b/bin/npm-cli.js @@ -25,7 +25,6 @@ unsupported.checkForUnsupportedNode() - var path = require('path') var npm = require('../lib/npm.js') var npmconf = require('../lib/config/core.js') var errorHandler = require('../lib/utils/error-handler.js') @@ -37,7 +36,7 @@ // if npm is called as "npmg" or "npm_g", then // run in global mode. - if (path.basename(process.argv[1]).slice(-1) === 'g') { + if (process.argv[1][process.argv[1].length - 1] === 'g') { process.argv.splice(1, 1, 'npm', '-g') }