You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2016/10/11 23:31:55 UTC
cordova-lib git commit: CB-11998 - cordova platform add error with
cordova-common@1.5.0
Repository: cordova-lib
Updated Branches:
refs/heads/master 20f40d9c0 -> c44db3d7a
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-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/c44db3d7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/c44db3d7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/c44db3d7
Branch: refs/heads/master
Commit: c44db3d7a00779d5c7eb5ae6150847156858a4f7
Parents: 20f40d9
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Oct 11 15:52:40 2016 -0700
Committer: Steve Gill <st...@gmail.com>
Committed: Tue Oct 11 16:31:48 2016 -0700
----------------------------------------------------------------------
cordova-common/spec/FileUpdater.spec.js | 76 ++++++++++++++++++++++++++++
cordova-common/src/FileUpdater.js | 2 +-
2 files changed, 77 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/c44db3d7/cordova-common/spec/FileUpdater.spec.js
----------------------------------------------------------------------
diff --git a/cordova-common/spec/FileUpdater.spec.js b/cordova-common/spec/FileUpdater.spec.js
index 4f66331..5cdab8c 100644
--- a/cordova-common/spec/FileUpdater.spec.js
+++ b/cordova-common/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-lib/blob/c44db3d7/cordova-common/src/FileUpdater.js
----------------------------------------------------------------------
diff --git a/cordova-common/src/FileUpdater.js b/cordova-common/src/FileUpdater.js
index e97df5b..8b6876b 100644
--- a/cordova-common/src/FileUpdater.js
+++ b/cordova-common/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