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

Use pump library in steal-tools build code #703

Merged
merged 1 commit into from
May 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
41 changes: 15 additions & 26 deletions lib/build/multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ It manipulates this graph and eventually creates "bundle" graphs. Bundle graphs
The nodes in those bundles are written to the filesystem.

*/
var pump = require("pump");
var assignDefaultOptions = require("../assign_default_options");
var bundle = require("../stream/bundle");
var createBundleGraphStream = require("../graph/make_graph_with_bundles").createBundleGraphStream;
Expand Down Expand Up @@ -88,22 +89,21 @@ module.exports = function(config, options){
return Promise.reject(err);
}

// Get a stream containing the bundle graph
var graphStream = createBundleGraphStream(config, options);
// Pipe the bundle graph into the multiBuild steps
var transpileStream = graphStream.pipe(transpile());
var minifyStream = transpileStream.pipe(minify());
var buildStream = minifyStream.pipe(bundle());
//var buildStream = graphStream.pipe(multiBuild());
// Pipe the buildStream into concatenation
var concatStream = buildStream.pipe(concat());

// Return a Promise that will resolve after bundles have been written;
return new Promise(function(resolve, reject){
var bundleWriteStream = concatStream.pipe(createWriteStream());

// Pipe the build result into a write stream.
var writeStream = bundleWriteStream.pipe(stealWriteStream());
return new Promise(function(resolve, reject) {
var writeStream = pump(
createBundleGraphStream(config, options),
transpile(),
minify(),
bundle(),
concat(),
createWriteStream(),
stealWriteStream(),
function(err) {
// reject the promise if any of the streams fail
if (err) reject(err);
}
);

writeStream.on("data", function(data){
this.end();
Expand All @@ -121,17 +121,6 @@ module.exports = function(config, options){

resolve(data);
});

[ graphStream,
transpileStream,
minifyStream,
buildStream,
bundleWriteStream,
writeStream
].forEach(function(stream){
stream.on("error", reject);
});
});
}

};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"mocha-lcov-reporter": "^1.2.0",
"mock-fs": "4.2.0",
"mockery": "^2.0.0",
"pump": "^1.0.2",
"rimraf": "^2.5.2",
"serve-static": "^1.11.2",
"steal-conditional": "^0.3.4",
Expand Down