Skip to content
Open
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
3 changes: 2 additions & 1 deletion lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ async function install (gyp, argv) {
log.verbose('tmpdir == cwd', 'automatically will remove dev files after to save disk space')
gyp.todo.push({ name: 'remove', args: argv })
}
return gyp.commands.install([noretry].concat(argv))
// The version to install is read from argv[0], so the sentinel goes on the end.
return gyp.commands.install(argv.concat([noretry]))
}
}

Expand Down
37 changes: 37 additions & 0 deletions test/test-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,43 @@ describe('install', function () {
}
})

it('EACCES retry keeps the requested version', async () => {
const argvs = []
const mockInstall = requireInject('../lib/install', {
'graceful-fs': {
promises: {
stat (_) {
const err = new Error()
err.code = 'EACCES'
throw err
}
}
}
})
const Gyp = {
devDir: __dirname,
opts: {
ensure: true
},
commands: {
install: (...args) => {
argvs.push(args[0])
return mockInstall(Gyp, ...args)
},
remove: async () => {}
}
}

try {
await Gyp.commands.install(['99.0.0'])
} catch (e) {
// the install itself cannot succeed here, only the argv it retries with matters
}

assert.equal(argvs.length, 2)
assert.equal(argvs[1][0], '99.0.0')
})

describe('parallel', function () {
let prog

Expand Down
Loading