Last active
October 4, 2015 23:17
-
-
Save yorickvP/2714588 to your computer and use it in GitHub Desktop.
Browserify dependency listing
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
#!/usr/bin/env node | |
// works as a CLI similar to the browserify one, but prints a space-separated list of dependencies for the arguments you give. | |
// requires browserify (obviously), JSONStream and event-stream. | |
var JSONStream = require('JSONStream') | |
, child_process = require('child_process') | |
, path = require('path') | |
, es = require('event-stream') | |
var parser = JSONStream.parse([true]) | |
var cwd = process.cwd() | |
var child = child_process.spawn('node_modules/.bin/browserify', ['--deps'].concat(process.argv.slice(1))) | |
child.stdout | |
.pipe(JSONStream.parse([true, 'id'])) | |
.pipe(es.mapSync(path.relative.bind(path, cwd))) | |
.pipe(es.join(' ')) | |
.pipe(process.stdout) | |
child.stderr | |
.pipe(process.stderr) | |
child.on('exit', function(code, signal) { process.exit(code) } |
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
# one would use it for makefiles like so: | |
web/static/depend/js/browserify.bundle.js.d: web/src/js/browserify.entry.js | |
@echo Generate $@ | |
echo -n "web/static/js/browserify.bundle.js: " > $@ | |
./browserify-makedep.js $+ >> $@ | |
-include web/static/depend/js/browserify.bundle.js.d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment