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

Commit

Permalink
fix(installer): improvements to automatic lazy require workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Nov 12, 2018
1 parent be8735c commit 45faca8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 6 additions & 0 deletions lib/installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class Installer {
this.tree.delDep(dep)
}
}
if (!this.tree.dependencies.size) {
throw new Error('No dependencies found matching filter')
}
}
this.log('silly', 'tree', this.tree)
this.expectedTotal = 0
Expand Down Expand Up @@ -311,7 +314,10 @@ class Installer {
}

async tinkifyBins () {
const old = process.tink
process.tink = null
const bins = await glob(path.join(this.prefix, 'node_modules/**/.bin/*'))
process.tink = old
this.log('verbose', 'tinkifyBins', 'convering installed bins to use tink:', bins)
return BB.map(bins, async bin => {
const real = await realpathAsync(bin)
Expand Down
10 changes: 7 additions & 3 deletions lib/lock-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ async function main (cache, integrity, pkg) {
other () { return true }
})
opts.log.heading = 'tink'
opts.log.level = opts.loglevel
opts.log.notice('fs', 'unpacking', `${pkg.name}@${pkg.version}`)
try {
if (!prepare) { prepare = require('./commands/prepare.js') }
const { pkgCount } = await prepare.handler(opts, [pkg.name])
if (!pkgCount) { throw new Error('no packages installed') }
opts.log.level = 'silent'
const res = await prepare.handler(opts.concat({
loglevel: 'silent'
}), [pkg.name])
if (res && !res.pkgCount) { throw new Error('no packages installed') }
} catch (err) {
throw err
if (!ensurePkg) { ensurePkg = require('./ensure-package.js') }
opts.log.level = opts.loglevel
await ensurePkg(cache, pkg.name, pkg, opts)
}
}
9 changes: 1 addition & 8 deletions lib/pkglock.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,7 @@ async function fetchPackage (cache, pkg, hash) {
if (!ensurePkg) { ensurePkg = require('./ensure-package.js') }
if (!config) { config = require('./config.js') }
if (!ensureDep) { ensureDep = require('./lock-worker.js') }
try {
await ensureDep(cache, hash, pkg)
} catch (err) {
await ensurePkg(cache, pkg.name, pkg, config().concat({
cache,
integrity: hash
}))
}
await ensureDep(cache, hash, pkg)
}

function fetchPackageSync (cache, pkg, integrity) {
Expand Down

0 comments on commit 45faca8

Please sign in to comment.