fix js error reporting
This commit is contained in:
parent
20f4e7621b
commit
8d255137d9
|
@ -62,7 +62,7 @@ class Pipeline {
|
|||
async.waterfall([
|
||||
|
||||
function findImports(next) {
|
||||
self.webpackRun(file.filename, {}, false, importsList, next);
|
||||
self.webpackRun(file.filename, {}, false, importsList, false, next);
|
||||
},
|
||||
|
||||
function changeCwd(next) {
|
||||
|
@ -71,27 +71,28 @@ class Pipeline {
|
|||
next();
|
||||
},
|
||||
|
||||
function findImportsPhase2(next) {
|
||||
self.webpackRun(file.filename, {
|
||||
externals: function(context, request, callback) {
|
||||
if (request === utils.joinPath(fs.dappPath(), file.filename)) {
|
||||
callback();
|
||||
} else {
|
||||
//if (request.indexOf('Embark/contracts/') === 0) {
|
||||
// let contractName = request.split('/')[2];
|
||||
// let contractCode = self.buildContractJS(contractName);
|
||||
// let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
|
||||
// fs.writeFileSync(filePath, contractCode);
|
||||
// importsList[request] = filePath;
|
||||
//function findImportsPhase2(next) {
|
||||
// console.log("====> findImports_2");
|
||||
// self.webpackRun(file.filename, {
|
||||
// externals: function(context, request, callback) {
|
||||
// if (request === utils.joinPath(fs.dappPath(), file.filename)) {
|
||||
// callback();
|
||||
// } else {
|
||||
// //if (request.indexOf('Embark/contracts/') === 0) {
|
||||
// // let contractName = request.split('/')[2];
|
||||
// // let contractCode = self.buildContractJS(contractName);
|
||||
// // let filePath = utils.joinPath(fs.dappPath(), ".embark", contractName + '.js');
|
||||
// // fs.writeFileSync(filePath, contractCode);
|
||||
// // importsList[request] = filePath;
|
||||
// //}
|
||||
// callback(null, "amd " + Math.random());
|
||||
// }
|
||||
callback(null, "amd " + Math.random());
|
||||
}
|
||||
}
|
||||
}, true, importsList, next);
|
||||
},
|
||||
// }
|
||||
// }, true, importsList, next);
|
||||
//},
|
||||
|
||||
function runWebpack(next) {
|
||||
self.webpackRun(file.filename, {}, true, importsList, next);
|
||||
self.webpackRun(file.filename, {}, true, importsList, true, next);
|
||||
},
|
||||
|
||||
function changeCwdBack(next) {
|
||||
|
@ -99,9 +100,14 @@ class Pipeline {
|
|||
next();
|
||||
}
|
||||
|
||||
], function(_err, _result) {
|
||||
], function(err, _result) {
|
||||
if (err) {
|
||||
process.chdir(realCwd);
|
||||
self.logger.error(err);
|
||||
return fileCb(err);
|
||||
}
|
||||
if (!fs.existsSync('./.embark/' + file.filename)) {
|
||||
self.logger.error("coudln't find file: " + file.filename);
|
||||
self.logger.error("couldn't find file: " + file.filename);
|
||||
return fileCb("couldn't find file: " + file.filename);
|
||||
}
|
||||
let fileContent = fs.readFileSync('./.embark/' + file.filename).toString();
|
||||
|
@ -159,7 +165,7 @@ class Pipeline {
|
|||
});
|
||||
}
|
||||
|
||||
webpackRun(filename, options, includeModules, importsList, callback) {
|
||||
webpackRun(filename, options, includeModules, importsList, detectErrors, callback) {
|
||||
let defaultOptions = {
|
||||
entry: utils.joinPath(fs.dappPath(), filename),
|
||||
output: {
|
||||
|
@ -210,6 +216,13 @@ class Pipeline {
|
|||
}
|
||||
|
||||
webpack(webpackOptions).run((_err, _stats) => {
|
||||
if (!detectErrors) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (_stats.hasErrors()) {
|
||||
return callback(_stats.toJson().errors.join("\n"));
|
||||
}
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue