Chuck Jazdzewski 43d3a84df3 Revert "refactor: add license header to JS files & format files (#12035)"
This reverts commit 8310c918236c2bc085a0fd4278ee96106c5c2f1a.
2016-10-04 14:06:41 -07:00

33 lines
642 B
JavaScript

var webpack = require('webpack');
/**
* Wraps the original `webpack` function to convert execution
* result to a promise and properly report errors.
*
* @param options
* @returns {Function}
*/
function webPackPromiseify(options) {
return new Promise(function (resolve, reject) {
webpack(options, function(err, stats) {
var jsonStats = stats.toJson() || {};
var statsErrors = jsonStats.errors || [];
if (err) {
return reject(err);
}
if (statsErrors.length) {
return reject(statsErrors);
}
return resolve(stats);
});
});
}
module.exports = webPackPromiseify;