This repository has been archived by the owner on Jul 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(log): get logging config to propagate correctly
Also made current tink config globally accessible (will remove in --production mode)
- Loading branch information
Showing
4 changed files
with
20 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
'use strict' | ||
|
||
let config | ||
let ensurePkg | ||
let prepare | ||
|
||
const figgyPudding = require('figgy-pudding') | ||
|
||
const MainOpts = figgyPudding({ | ||
log: { default: () => require('libnpm').log }, | ||
loglevel: { default: 'notice' } | ||
}, { | ||
other () { return true } | ||
}) | ||
|
||
if (require.main === module && process.argv[2] === 'ensure-pkg') { | ||
main(...process.argv.slice(3)) | ||
} | ||
|
||
module.exports = main | ||
async function main (cache, integrity, pkg) { | ||
pkg = JSON.parse(pkg) | ||
if (!config) { config = require('./config.js') } | ||
const opts = config().concat({ | ||
async function main (cache, integrity, pkg, opts) { | ||
opts = MainOpts(JSON.parse(opts)).concat({ | ||
cache, | ||
integrity, | ||
log: require('npmlog'), | ||
// loglevel: 'silly', | ||
'restore-missing': true, | ||
force: true | ||
}, { | ||
other () { return true } | ||
}) | ||
pkg = JSON.parse(pkg) | ||
opts.log.heading = 'tink' | ||
opts.log.notice('fs', 'unpacking', `${pkg.name}@${pkg.version}`) | ||
opts.log.level = opts.loglevel | ||
opts.log.notice('fs', 'fetching', `${pkg.name}@${pkg.version}`) | ||
try { | ||
if (!prepare) { prepare = require('./commands/prepare.js') } | ||
opts.log.level = 'silent' | ||
const res = await prepare.handler(opts.concat({ | ||
loglevel: 'silent' | ||
}), [pkg.name]) | ||
const res = await prepare.handler(opts, [pkg.name]) | ||
if (res && !res.pkgCount) { throw new Error('no packages installed') } | ||
} catch (err) { | ||
if (!ensurePkg) { ensurePkg = require('./ensure-package.js') } | ||
opts.log.level = opts.loglevel | ||
await ensurePkg(cache, pkg.name, pkg, opts) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters