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