From d208a6458775b0d21cbeee82094b8b3335c1eeaa Mon Sep 17 00:00:00 2001 From: Avi Block Date: Sun, 1 Feb 2015 04:45:54 -0500 Subject: [PATCH 1/2] Provide `--full-paths` option to browerify in third example This option creates the `module-deps` output using the full path of the module. Without this, factor-bundle cannot correspond the module id to the actual module. --- readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.markdown b/readme.markdown index 7653bda..18cac73 100644 --- a/readme.markdown +++ b/readme.markdown @@ -54,7 +54,7 @@ $ module-deps x.js y.js | factor-bundle \ or factor out an existing bundle already compiled by browserify: ``` sh -$ browserify x.js y.js > bundle.js +$ browserify --full-paths x.js y.js > bundle.js $ browser-unpack < bundle.js | factor-bundle \ x.js -o bundle/x.js \ y.js -o bundle/y.js \ From efac1e8c69bbe5f8dbdac71a0e00c377d4af4dec Mon Sep 17 00:00:00 2001 From: Avi Block Date: Sun, 1 Feb 2015 08:07:38 -0500 Subject: [PATCH 2/2] Create subdirectories that don't exist --- bin/cmd.js | 9 +++++++-- package.json | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/cmd.js b/bin/cmd.js index 5d45348..ab0c92c 100755 --- a/bin/cmd.js +++ b/bin/cmd.js @@ -6,6 +6,7 @@ var factor = require('../'); var minimist = require('minimist'); var pack = require('browser-pack'); var Transform = require('stream').Transform; +var mkdirp = require('mkdirp'); var argv = minimist(process.argv.slice(2)); if (argv.h || argv.help || argv._.length === 0) { @@ -25,7 +26,11 @@ var output = argv.o.length > files.length && argv.o[files.length] !== '-' ; fr.on('stream', function (bundle) { - var ws = fs.createWriteStream(files[bundle.file]); - bundle.pipe(pack({ raw: true })).pipe(ws); + + mkdirp(path.dirname(files[bundle.file]), function(err) { + var ws = fs.createWriteStream(files[bundle.file]); + bundle.pipe(pack({ raw: true })).pipe(ws); + }); }); + process.stdin.pipe(fr).pipe(pack({ raw: true })).pipe(output); diff --git a/package.json b/package.json index be65392..c254e40 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "inherits": "^2.0.1", "labeled-stream-splicer": "^1.0.0", "minimist": "~0.2.0", + "mkdirp": "^0.5.0", "nub": "0.0.0", "reversepoint": "~0.2.0", "stream-combiner": "~0.2.1",