chore(build): Migrate remaining tasks under build.js.dev to broccoli.
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var broccoli = require('broccoli');
|
||||
var copyDereferenceSync = require('copy-dereference').sync;
|
||||
var fse = require('fs-extra');
|
||||
var path = require('path');
|
||||
var printSlowTrees = require('broccoli-slow-trees');
|
||||
|
||||
|
||||
module.exports = broccoliBuild;
|
||||
var broccoliExecuted = {};
|
||||
@ -29,24 +33,43 @@ function broccoliBuild(tree, outputRoot) {
|
||||
var builder = new broccoli.Builder(tree);
|
||||
return builder.build()
|
||||
.then(function (hash) {
|
||||
printSlowTrees(hash.graph);
|
||||
|
||||
var dir = hash.directory;
|
||||
try {
|
||||
copyDereferenceSync(path.join(dir, outputRoot), distPath);
|
||||
time('Write build output', function() {
|
||||
copyDereferenceSync(path.join(dir, outputRoot), distPath);
|
||||
});
|
||||
} catch (err) {
|
||||
if (err.code === 'EEXIST') err.message += ' (we cannot build into an existing directory)';
|
||||
throw err;
|
||||
}
|
||||
})
|
||||
.finally(function () {
|
||||
builder.cleanup();
|
||||
time('Build cleanup', function() {
|
||||
builder.cleanup();
|
||||
});
|
||||
})
|
||||
.catch(function (err) {
|
||||
// Should show file and line/col if present
|
||||
if (err.file) {
|
||||
console.error('File: ' + err.file);
|
||||
}
|
||||
console.error(err.stack);
|
||||
if (err.stack) {
|
||||
console.error(err.stack);
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
console.error('\nBuild failed');
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function time(label, work) {
|
||||
|
||||
var start = Date.now();
|
||||
work();
|
||||
var duration = Date.now() - start;
|
||||
console.log("%s: %dms", label, duration);
|
||||
}
|
||||
|
Reference in New Issue
Block a user