parent
cbbc1c7333
commit
e64d86c1eb
@ -258,6 +258,7 @@ export default class OptionManager {
|
||||
}
|
||||
|
||||
let presetLoc;
|
||||
try {
|
||||
if (typeof val === "string") {
|
||||
presetLoc = resolve(`babel-preset-${val}`, dirname) || resolve(val, dirname);
|
||||
if (!presetLoc) {
|
||||
@ -285,7 +286,13 @@ export default class OptionManager {
|
||||
throw new Error(`Unsupported preset format: ${val}.`);
|
||||
}
|
||||
|
||||
onResolve && onResolve(val);
|
||||
onResolve && onResolve(val, presetLoc);
|
||||
} catch (e) {
|
||||
if (presetLoc) {
|
||||
e.message += ` (While processing preset: ${JSON.stringify(presetLoc)})`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
return val;
|
||||
});
|
||||
}
|
||||
|
||||
3
packages/babel-core/test/fixtures/option-manager/not-a-preset.js
vendored
Normal file
3
packages/babel-core/test/fixtures/option-manager/not-a-preset.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
module.exports = function () {
|
||||
throw new Error('Not a real preset');
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
var assert = require("assert");
|
||||
var OptionManager = require("../lib/transformation/file/options/option-manager");
|
||||
var Logger = require("../lib/transformation/file/logger");
|
||||
var path = require("path");
|
||||
|
||||
suite("option-manager", function () {
|
||||
suite("memoisePluginContainer", function () {
|
||||
@ -43,5 +44,16 @@ suite("option-manager", function () {
|
||||
/Using removed Babel 5 option: base.auxiliaryComment - Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`/
|
||||
);
|
||||
})
|
||||
test("throws for resolved but erroring preset", function() {
|
||||
return assert.throws(
|
||||
function () {
|
||||
var opt = new OptionManager(new Logger(null, "unknown"));
|
||||
opt.init({
|
||||
'presets': [path.resolve(__dirname, "fixtures", "option-manager", "not-a-preset")]
|
||||
});
|
||||
},
|
||||
/While processing preset: .*option-manager(?:\/|\\\\)not-a-preset\.js/
|
||||
);
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user