Browse Source

Make copy of .amd.json contents. Fix #2.

Herbert Vojčík 8 years ago
parent
commit
9ca914f2a2
2 changed files with 19 additions and 2 deletions
  1. 1 1
      lib/config-builder.js
  2. 18 1
      test/produce.js

+ 1 - 1
lib/config-builder.js

@@ -116,7 +116,7 @@ exports.produceConfigObject = function (root, callback) {
         var result = {};
         for (var i = 0; i < queue.length; i++) {
             var file = queue[i];
-            var json = require(file);
+            var json = JSON.parse(JSON.stringify(require(file)));
             transformShimDeps(json);
             transformPaths(json, root, file, dirMap);
             _.merge(result, json, function (a, b) {

+ 18 - 1
test/produce.js

@@ -165,7 +165,24 @@ describe('#produceConfigObject paths', function () {
         });
     });
 
-    it('should works with array paths correctly', function (done) {
+    it('should work with array paths correctly', function (done) {
+        builder.produceConfigObject(fixture('arrays-in-paths'), function (err, result) {
+            assert.ifError(err);
+            assert.deepEqual(result, {
+                paths: {
+                    dot0: ".", rel0: "relative", sibling0: "../sibling", abs0: "/absolute", uri0: "http://example.com/uri",
+                    arr0: [".", "relative", "../sibling", "/absolute", "http://example.com/uri"],
+                    dot1: "deep", rel1: "deep/relative", sibling1: "sibling", abs1: "/absolute", uri1: "http://example.com/uri",
+                    arr1: ["deep", "deep/relative", "sibling", "/absolute", "http://example.com/uri"],
+                    dot2: "z2/other", rel2: "z2/other/relative", sibling2: "z2/sibling", abs2: "/absolute", uri2: "http://example.com/uri",
+                    arr2: ["z2/other", "z2/other/relative", "z2/sibling", "/absolute", "http://example.com/uri"]
+                }
+            });
+            done();
+        });
+    });
+
+    it('should work with same paths correctly if used more times', function (done) {
         builder.produceConfigObject(fixture('arrays-in-paths'), function (err, result) {
             assert.ifError(err);
             assert.deepEqual(result, {