Skip to content
This repository has been archived by the owner on May 10, 2021. It is now read-only.

Commit

Permalink
fix(prefix): oops @ prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Jan 7, 2018
1 parent d4576ed commit cc5adac
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Installer {
}

run () {
const prefix = this.config.get('prefix')
const prefix = this.prefix
return this.prepare()
.then(() => this.extractTree(this.tree))
.then(() => this.buildTree(this.tree))
Expand Down Expand Up @@ -72,12 +72,12 @@ class Installer {
)
})
.then(() => statAsync(
path.join(this.config.get('prefix'), 'node_modules')
path.join(this.prefix, 'node_modules')
).catch(err => { if (err.code !== 'ENOENT') { throw err } }))
.then(stat => {
return BB.join(
this.checkLock(),
stat && rimraf(path.join(this.config.get('prefix'), 'node_modules'))
stat && rimraf(path.join(this.prefix, 'node_modules'))
)
}).then(() => {
// This needs to happen -after- we've done checkLock()
Expand All @@ -91,7 +91,7 @@ class Installer {

checkLock () {
const pkg = this.pkg
const prefix = this.config.get('prefix')
const prefix = this.prefix
if (!pkg._shrinkwrap || !pkg._shrinkwrap.lockfileVersion) {
return BB.reject(
new Error(`cipm can only install packages with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or later to generate it, then try again.`)
Expand All @@ -109,13 +109,15 @@ class Installer {
result.errors.join('\n') + '\n'
)
}
}).catch(err => {
throw err
})
}

extractTree (tree) {
return tree.forEachAsync((dep, next) => {
if (dep.dev && this.config.get('production')) { return }
const depPath = dep.path(this.config.get('prefix'))
const depPath = dep.path(this.prefix)
// Process children first, then extract this child
return BB.join(
!dep.isRoot &&
Expand All @@ -128,7 +130,7 @@ class Installer {
buildTree (tree) {
return tree.forEachAsync((dep, next) => {
if (dep.dev && this.config.get('production')) { return }
const depPath = dep.path(this.config.get('prefix'))
const depPath = dep.path(this.prefix)
return readPkgJson(path.join(depPath, 'package.json'))
.then(pkg => {
return this.runScript('preinstall', pkg, depPath)
Expand All @@ -140,8 +142,8 @@ class Installer {
log: this.log,
name: pkg.name,
pkgId: pkg.name + '@' + pkg.version,
prefix: this.config.get('prefix'),
prefixes: [this.config.get('prefix')],
prefix: this.prefix,
prefixes: [this.prefix],
umask: this.config.get('umask')
}), e => {})
.then(() => this.runScript('install', pkg, depPath))
Expand All @@ -163,7 +165,7 @@ class Installer {
if (!this.failedDeps.size) { return }
return sweep(
tree,
this.config.get('prefix'),
this.prefix,
mark(tree, this.failedDeps)
)
.then(purged => {
Expand Down

0 comments on commit cc5adac

Please sign in to comment.