Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pack: add dryRun option to packDirectory #47

Merged
merged 3 commits into from
Aug 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pack: move --dry-run logging
Move --dry-run logging closer to original position.
  • Loading branch information
larsgw authored Aug 14, 2018
commit e740633025912473101d702c3597f30841f42b6d
8 changes: 4 additions & 4 deletions lib/pack.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,13 @@ function pack_ (pkg, dir) {
const target = `${name}-${mani.version}.tgz`
return pinflight(target, () => {
const dryRun = npm.config.get('dry-run')
if (dryRun) {
log.verbose('pack', '--dry-run mode enabled. Skipping write.')
}
if (mani._requested.type === 'directory') {
return prepareDirectory(mani._resolved)
.then(() => {
return packDirectory(mani, mani._resolved, target, target, true, dryRun)
})
} else if (dryRun) {
log.verbose('pack', '--dry-run mode enabled. Skipping write.')
return cacache.tmp.withTmp(npm.tmp, {tmpPrefix: 'packing'}, (tmp) => {
const tmpTarget = path.join(tmp, path.basename(target))
return packFromPackage(pkg, tmpTarget, target)
Expand Down Expand Up @@ -159,7 +157,9 @@ function packDirectory (mani, dir, target, filename, logIt, dryRun) {
.then(() => getContents(pkg, tmpTarget, filename, logIt))
// thread the content info through
.tap(() => {
if (!dryRun) {
if (dryRun) {
log.verbose('pack', '--dry-run mode enabled. Skipping write.')
} else {
return move(tmpTarget, target, {Promise: BB, fs})
}
})
Expand Down