Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lib/cli/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ module.exports = async (process, validateEngines) => {
// leak any private CLI configs to other programs
process.title = 'npm'

// if npm is called as "npmg" or "npm_g", then run in global mode.
if (process.argv[1][process.argv[1].length - 1] === 'g') {
process.argv.splice(1, 1, 'npm', '-g')
}

// Patch the global fs module here at the app level
require('graceful-fs').gracefulify(require('node:fs'))

Expand Down
8 changes: 4 additions & 4 deletions test/lib/cli/entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ const cliMock = async (t, opts) => {
}
}

t.test('print the version, and treat npm_g as npm -g', async t => {
t.test('print the version ', async t => {
const { logs, cli, Npm, outputs, exitHandlerCalled } = await cliMock(t, {
globals: { 'process.argv': ['node', 'npm_g', 'root'] },
globals: { 'process.argv': ['node', 'npm', 'root'] },
})
await cli(process)

t.strictSame(process.argv, ['node', 'npm', '-g', 'root'], 'system process.argv was rewritten')
t.strictSame(process.argv, ['node', 'npm', 'root'], 'system process.argv was rewritten')
t.strictSame(logs.verbose.byTitle('cli'), ['cli node npm'])
t.strictSame(logs.verbose.byTitle('title'), ['title npm root'])
t.match(logs.verbose.byTitle('argv'), ['argv "--global" "root"'])
t.match(logs.verbose.byTitle('argv'), ['argv "root"'])
t.strictSame(logs.info, [`using npm@${Npm.version}`, `using node@${process.version}`])
t.equal(outputs.length, 1)
t.match(outputs[0], dirname(process.cwd()))
Expand Down
Loading