Browse Source

less deeper setting prevail

Herbert Vojčík 9 years ago
parent
commit
6b1f7c7ac9

+ 1 - 1
lib/config-builder.js

@@ -90,7 +90,7 @@ function queoeOfFilesToProcess(files, dirMap) {
             throw new Error("No location for " + file);
         }
     }
-    return  firstPass.concat(secondPass);
+    return  firstPass.reverse().concat(secondPass.reverse());
 }
 
 exports.produceConfigObject = function (root, callback) {

+ 19 - 0
test/produce.js

@@ -66,6 +66,16 @@ describe('#produceConfigObject merging', function () {
         });
     });
 
+    it('should include both local.amd.json if root and deep are present, deep first', function (done) {
+        builder.produceConfigObject(fixture('two-locals-with-shared'), function (err, result) {
+            assert.ifError(err);
+            assert.deepEqual(result, {
+                config: {foo: {foo: "bar"}, fooDeep: {foo: "bar"}, shared: "root"}
+            });
+            done();
+        });
+    });
+
     it('should include {root,deep}/local.amd.json first and {foo,bar}.amd.json afterwards given {foo,bar} dir is present', function (done) {
         builder.produceConfigObject(fixture('two-locals-two-others'), function (err, result) {
             assert.ifError(err);
@@ -76,6 +86,15 @@ describe('#produceConfigObject merging', function () {
         });
     });
 
+    it('should include {root,deep}/local.amd.json first and {foo,bar}.amd.json afterwards given {foo,bar} dir is present, deeps first', function (done) {
+        builder.produceConfigObject(fixture('two-locals-two-others-with-shared'), function (err, result) {
+            assert.ifError(err);
+            assert.deepEqual(result, {
+                config: {a: 2, b: 2, c: 2, d: 2, e: 1, f: 1, g: 2, h: 1}
+            });
+            done();
+        });
+    });
 });
 
 describe('#produceConfigObject knows to deal with shims', function () {

+ 5 - 0
test/two-locals-two-others-with-shared/deep/local.amd.json

@@ -0,0 +1,5 @@
+{
+    "config": {
+        "a": 1, "b": 1, "e": 1, "g": 1
+    }
+}

+ 5 - 0
test/two-locals-two-others-with-shared/local.amd.json

@@ -0,0 +1,5 @@
+{
+    "config": {
+        "c": 1, "d": 1, "f": 1, "g": 2
+    }
+}

+ 5 - 0
test/two-locals-two-others-with-shared/other.amd.json

@@ -0,0 +1,5 @@
+{
+    "config": {
+        "b": 2, "c": 2, "h": 1
+    }
+}

+ 5 - 0
test/two-locals-two-others-with-shared/other/deep.amd.json

@@ -0,0 +1,5 @@
+{
+    "config": {
+        "a": 2, "d": 2, "h": 2
+    }
+}

+ 6 - 0
test/two-locals-with-shared/deep/local.amd.json

@@ -0,0 +1,6 @@
+{
+    "config": {
+        "fooDeep": {"foo": "bar"},
+        "shared": "deep"
+    }
+}

+ 6 - 0
test/two-locals-with-shared/local.amd.json

@@ -0,0 +1,6 @@
+{
+    "config": {
+        "foo": {"foo": "bar"},
+        "shared": "root"
+    }
+}