Fix: config lookup logic in babel-core (#5550)

This fixes a bug that was causing the config lookup to stop
when a package.json file was found even if it did not contain a
"babel" key.
This commit is contained in:
Kai Cataldo 2017-03-27 14:54:57 -04:00 committed by Logan Smyth
parent 7a1ccf076c
commit 1f2f63ccdf
4 changed files with 60 additions and 1 deletions

View File

@ -163,7 +163,7 @@ class ConfigChainBuilder {
this.errorMultipleConfigs(arr.pop(), config);
}
arr.push(config);
if (configAdded) arr.push(config);
}
return arr;

View File

@ -128,6 +128,59 @@ describe("buildConfigChain", function () {
assert.deepEqual(chain, expected);
});
it("dir3", function () {
const chain = buildConfigChain({
filename: fixture("dir3", "src.js"),
});
const expected = [
{
type: "options",
options: {
plugins: [
"extended",
],
},
alias: fixture("extended.babelrc.json"),
loc: fixture("extended.babelrc.json"),
dirname: fixture(),
},
{
type: "options",
options: {
plugins: [
"root",
],
},
alias: fixture(".babelrc"),
loc: fixture(".babelrc"),
dirname: fixture(),
},
{
type: "options",
options: {
ignore: [
"root-ignore",
],
},
alias: fixture(".babelignore"),
loc: fixture(".babelignore"),
dirname: fixture(),
},
{
type: "arguments",
options: {
filename: fixture("dir3", "src.js"),
},
alias: "base",
loc: "base",
dirname: base(),
},
];
assert.deepEqual(chain, expected);
});
it("env - base", function () {
const chain = buildConfigChain({
filename: fixture("env", "src.js"),

View File

@ -0,0 +1,5 @@
{
"name": "application-name",
"version": "0.0.1"
}

View File

@ -0,0 +1 @@
// empty