Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Commit

Permalink
fix(install): prevent concurrent npx runs from clobbering each other
Browse files Browse the repository at this point in the history
Fixes: #56
  • Loading branch information
zkat committed Jul 11, 2017
1 parent 9b24359 commit 6b35c91
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,13 @@ function ensurePackages (specs, opts) {
return (
opts.cache ? Promise.resolve(opts.cache) : getNpmCache(opts)
).then(cache => {
const prefix = path.join(cache, '_npx')
const prefix = path.join(cache, '_npx', process.pid.toString())
const bins = process.platform === 'win32'
? prefix
: path.join(prefix, 'bin')
return promisify(require('rimraf'))(bins).then(() => {
const rimraf = promisify(require('rimraf'))
process.on('exit', () => rimraf.sync(prefix))
return rimraf(bins).then(() => {
return installPackages(specs, prefix, opts)
}).then(info => {
// This will make temp bins _higher priority_ than even local bins.
Expand Down

0 comments on commit 6b35c91

Please sign in to comment.