Skip to content

Commit

Permalink
fix(install): passing the right cwd to the runner
Browse files Browse the repository at this point in the history
  • Loading branch information
watilde committed Sep 8, 2017
1 parent 029f4e2 commit df8009d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/install/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ const installer = (dep, deps, base, resolve, reject) => {

fetch.then(() => {
return new Promise((resolve, reject) => {
const args = ['install']
const args = ['', 'install']
const pkg = require(path.join(target, 'package.json'))
if (!pkg.scripts || (
pkg.scripts.preinstall &&
pkg.scripts.install &&
pkg.scripts.postinstall
)) return resolve()
runner(args, pkg).then(resolve).catch(reject)
runner(args, pkg, target).then(resolve).catch(reject)
})
}).then(() => {
global.dependenciesCount += 1
Expand Down
9 changes: 6 additions & 3 deletions lib/run/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const spawn = require('child_process').spawn
const npmPath = require('npm-path')
const each = require('promise-each')

module.exports = (_, pkg) => {
module.exports = (_, pkg, cwd) => {
cwd = cwd || __dirname
const args = _.slice(1)
const scripts = pkg.scripts
const key = args.shift()
Expand All @@ -18,7 +19,7 @@ module.exports = (_, pkg) => {
env[npmPath.PATH] = newPath
return Promise.resolve(cmds).then(each((cmd) => {
return new Promise((resolve, reject) => {
const script = spawn(cmd, args, {shell: true, env: env})
const script = spawn(cmd, args, {cwd: cwd, shell: true, env: env})
script.stdout.on('data', (data) => {
process.stdout.write(data)
})
Expand All @@ -29,5 +30,7 @@ module.exports = (_, pkg) => {
resolve()
})
})
}))
})).catch((e) => {
throw new Error(e)
})
}

0 comments on commit df8009d

Please sign in to comment.