cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject [12/50] [abbrv] cordova-common git commit: CB-11998 - cordova platform add error with cordova-common@1.5.0
Date Tue, 06 Jun 2017 04:59:40 GMT
CB-11998 - cordova platform add error with cordova-common@1.5.0

 This closes #500


Project: http://git-wip-us.apache.org/repos/asf/cordova-common/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-common/commit/625e1533
Tree: http://git-wip-us.apache.org/repos/asf/cordova-common/tree/625e1533
Diff: http://git-wip-us.apache.org/repos/asf/cordova-common/diff/625e1533

Branch: refs/heads/master
Commit: 625e1533f2f24b3d1ff5f93f85e3cc7ea0a85483
Parents: 04d930a
Author: Shazron Abdullah <shazron@apache.org>
Authored: Tue Oct 11 15:52:40 2016 -0700
Committer: Steve Gill <stevengill97@gmail.com>
Committed: Tue Oct 11 16:31:48 2016 -0700

----------------------------------------------------------------------
 spec/FileUpdater.spec.js | 76 +++++++++++++++++++++++++++++++++++++++++++
 src/FileUpdater.js       |  2 +-
 2 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-common/blob/625e1533/spec/FileUpdater.spec.js
----------------------------------------------------------------------
diff --git a/spec/FileUpdater.spec.js b/spec/FileUpdater.spec.js
index 4f66331..5cdab8c 100644
--- a/spec/FileUpdater.spec.js
+++ b/spec/FileUpdater.spec.js
@@ -685,5 +685,81 @@ describe('FileUpdater class', function() {
                 testTargetDir,
                 null);
         });
+
+        it('should update files from merged source directories - with a rootDir', function
() {
+            var rootDir = path.join('Users', 'me');
+            mockFs.statMap[rootDir] = testDirStats;
+            mockFs.dirMap[rootDir] = [testSourceDir, testSourceDir2, testTargetDir];
+
+            mockFs.statMap[path.join(rootDir, testTargetDir)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testTargetDir)] = [testSubDir];
+            mockFs.statMap[path.join(rootDir, testTargetDir, testSubDir)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testTargetDir, testSubDir)] = [testSourceFile];
+            mockFs.statMap[path.join(rootDir, testTargetDir, testSubDir, testSourceFile)]
=
+                testFileStats;
+
+            mockFs.statMap[path.join(rootDir, testSourceDir)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testSourceDir)] = [testSubDir];
+            mockFs.statMap[path.join(rootDir, testSourceDir, testSubDir)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testSourceDir, testSubDir)] = [testSourceFile];
+            mockFs.statMap[path.join(rootDir, testSourceDir, testSubDir, testSourceFile)]
=
+                testFileStats2;
+
+            mockFs.statMap[path.join(rootDir, testSourceDir2)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testSourceDir2)] = [testSubDir];
+            mockFs.statMap[path.join(rootDir, testSourceDir2, testSubDir)] = testDirStats;
+            mockFs.dirMap[path.join(rootDir, testSourceDir2, testSubDir)] = [testSourceFile2];
+            mockFs.statMap[path.join(rootDir, testSourceDir2, testSubDir, testSourceFile2)]
=
+                testFileStats3;
+
+            var updated = FileUpdater.mergeAndUpdateDir(
+                [testSourceDir, testSourceDir2], testTargetDir, { rootDir: rootDir });
+            expect(updated).toBe(true);
+            expect(FileUpdater.updatePathWithStatsCalls.length).toBe(4);
+
+            function validateUpdatePathWithStatsCall(
+                    index, subPath, sourceDir, sourceStats, targetDir, targetStats) {
+                var args = FileUpdater.updatePathWithStatsCalls[index];
+                expect(args[0]).toBe(path.join(sourceDir, subPath));
+                expect(args[1]).toEqual(sourceStats);
+                expect(args[2]).toBe(path.join(targetDir, subPath));
+                expect(args[3]).toEqual(targetStats);
+                expect(args[4]).toBeDefined(); // rootDir is defined
+            }
+
+            // Update the root directory.
+            validateUpdatePathWithStatsCall(
+                0,
+                '',
+                testSourceDir2,
+                testDirStats,
+                testTargetDir,
+                testDirStats);
+            // Update the subdirectory.
+           validateUpdatePathWithStatsCall(
+                1,
+                testSubDir,
+                testSourceDir2,
+                testDirStats,
+                testTargetDir,
+                testDirStats);
+            // Update the first file, from the first source.
+            validateUpdatePathWithStatsCall(
+                2,
+                path.join(testSubDir, testSourceFile),
+                testSourceDir,
+                testFileStats2,
+                testTargetDir,
+                testFileStats);
+            // Update the second file, from the second source.
+            validateUpdatePathWithStatsCall(
+                3,
+                path.join(testSubDir, testSourceFile2),
+                testSourceDir2,
+                testFileStats3,
+                testTargetDir,
+                null);            
+        });
+
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-common/blob/625e1533/src/FileUpdater.js
----------------------------------------------------------------------
diff --git a/src/FileUpdater.js b/src/FileUpdater.js
index e97df5b..8b6876b 100644
--- a/src/FileUpdater.js
+++ b/src/FileUpdater.js
@@ -291,7 +291,7 @@ function mergeAndUpdateDir(sourceDirs, targetDir, options, log) {
             if (!fs.existsSync(sourcePath)) {
                 throw new Error("Source directory does not exist: " + sourcePath);
             }
-            return mapDirectory(rootDir, sourcePath, include, exclude);
+            return mapDirectory(rootDir, path.relative(rootDir, sourcePath), include, exclude);
         });
 
     // Scan the files in the target directory, if it exists.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message