From 90b7cbb334bd045bf9ea0a3c64a259505f1a535d Mon Sep 17 00:00:00 2001 From: Zach Bruggeman Date: Mon, 23 Mar 2015 14:58:28 -0700 Subject: [PATCH] Add prune option Fixes GH-4 --- index.js | 25 ++++++++++++++++++------- readme.md | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 8931c03..392bbe0 100644 --- a/index.js +++ b/index.js @@ -88,13 +88,24 @@ module.exports = function packager (opts, cb) { // copy users app into .app ncp(opts.dir, paths.app, {filter: filter}, function copied (err) { if (err) return cb(err) - - // finally, move app into cwd - var finalPath = opts.out || process.cwd() - // TODO dont spawn, but I couldn't find a good module - child.exec('mv "' + newApp + '" "' + finalPath + '"', function moved (err) { - cb(err, path.join(finalPath, opts.name + '.app')) - }) + + function moveApp (err) { + if (err) return cb(err) + + // finally, move app into cwd + var finalPath = opts.out || process.cwd() + // TODO dont spawn, but I couldn't find a good module + child.exec('mv "' + newApp + '" "' + finalPath + '"', function moved (err) { + cb(err, path.join(finalPath, opts.name + '.app')) + }) + } + + // run npm prune + if (opts.prune) { + child.exec('npm prune --production', { cwd: paths.app }, moveApp) + } else { + moveApp() + } }) } } diff --git a/readme.md b/readme.md index 09ecb47..0955488 100644 --- a/readme.md +++ b/readme.md @@ -36,3 +36,4 @@ these are optional CLI options you can pass in - `app-bundle-id` - bundle identifier to use in the app plist - `helper-bundle-id` - bundle identifier to use in the app helper plist - `ignore` (default none) - do not copy files into App whose filenames regex .match this string +- `prune` - runs `npm prune --production` on the app