Rewrite config chain loading to build chain recursively to keep caching readable.

This commit is contained in:
Logan Smyth
2017-12-19 18:10:51 -08:00
parent 7b861796cf
commit 758fd0369c
6 changed files with 1039 additions and 1000 deletions

View File

@@ -194,17 +194,50 @@ describe("buildConfigChain", function() {
assert.notEqual(opts1.plugins[0], opts2.plugins[1]);
});
it("should cache the env options by identity", () => {
const env = {
foo: {
plugins: plugins1,
it("should cache the env plugins by identity", () => {
const plugins = [() => ({})];
const opts1 = loadOptions({
envName: "foo",
env: {
foo: {
plugins,
},
},
};
});
const opts2 = loadOptions({
envName: "foo",
env: {
foo: {
plugins,
},
},
});
const opts1 = loadOptions({ envName: "foo", env });
assert.equal(opts1.plugins.length, 1);
assert.equal(opts2.plugins.length, 1);
assert.equal(opts1.plugins[0], opts2.plugins[0]);
});
env.foo.plugins = plugins2;
const opts2 = loadOptions({ envName: "foo", env });
it("should cache the env presets by identity", () => {
const presets = [() => ({ plugins: [() => ({})] })];
const opts1 = loadOptions({
envName: "foo",
env: {
foo: {
presets,
},
},
});
const opts2 = loadOptions({
envName: "foo",
env: {
foo: {
presets,
},
},
});
assert.equal(opts1.plugins.length, 1);
assert.equal(opts2.plugins.length, 1);