Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Created April 7, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terinjokes/0b198b330fabb52b6b5f to your computer and use it in GitHub Desktop.
Save terinjokes/0b198b330fabb52b6b5f to your computer and use it in GitHub Desktop.
var browserify = require('./');
var through = require('through2');
var b = browserify('./test/entry/main');
var spawn = require('child_process').spawn;
var wrap = b.pipeline.get('wrap');
var n = spawn('node');
var out = through();
var t = through(function(row, enc, next) {
this.push(new Buffer('alert("hello world");'));
next();
}, function(next) {
n.stdout.pipe(out);
n.stderr.pipe(process.stderr);
b.on('exit', function(code) {
if (code) {
b.emit('error', new Error('Exit ' + code));
}
next();
});
n.stdin.write('console.log(\'alert("hello, spawn");\')');
n.stdin.end();
});
wrap.push(t);
wrap.push(out);
b.bundle().pipe(process.stdout);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment