wWhen merging options, take precedence over the current array - fixes #2648
This commit is contained in:
@@ -7,13 +7,15 @@ export default function (dest?: Object, src?: Object): ?Object {
|
||||
|
||||
return merge(dest, src, function (a, b) {
|
||||
if (b && Array.isArray(a)) {
|
||||
let c = a.slice(0);
|
||||
for (let v of b) {
|
||||
if (a.indexOf(v) < 0) {
|
||||
c.push(v);
|
||||
let newArray = b.slice(0);
|
||||
|
||||
for (let item of a) {
|
||||
if (newArray.indexOf(item) < 0) {
|
||||
newArray.push(item);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
|
||||
return newArray;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,15 @@ function transformAsync(code, opts) {
|
||||
}
|
||||
|
||||
suite("api", function () {
|
||||
test("options merge backwards", function () {
|
||||
return transformAsync("", {
|
||||
presets: [__dirname + "/../../babel-preset-es2015"],
|
||||
plugins: [__dirname + "/../../babel-plugin-syntax-jsx"]
|
||||
}).then(function (result) {
|
||||
assert.ok(result.options.plugins[0][0].manipulateOptions.toString().indexOf("jsx") >= 0);
|
||||
});
|
||||
});
|
||||
|
||||
test("code option false", function () {
|
||||
return transformAsync("foo('bar');", { code: false }).then(function (result) {
|
||||
assert.ok(!result.code);
|
||||
|
||||
Reference in New Issue
Block a user