You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/08/12 23:06:36 UTC

git commit: Fix link/copy parent check for windows

Repository: cordova-lib
Updated Branches:
  refs/heads/master c60bd17d6 -> 13fe6b03b


Fix link/copy parent check for windows

Reported as cca issue #260
https://github.com/MobileChromeApps/mobile-chrome-apps/issues/260


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/13fe6b03
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/13fe6b03
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/13fe6b03

Branch: refs/heads/master
Commit: 13fe6b03bbfc86a5d2e5b565132946a7be2051fb
Parents: c60bd17
Author: Mark Koudritsky <ka...@gmail.com>
Authored: Tue Aug 12 16:53:16 2014 -0400
Committer: Mark Koudritsky <ka...@gmail.com>
Committed: Tue Aug 12 16:53:16 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/create.js | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/13fe6b03/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index 7aef292..c8cb694 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -105,11 +105,15 @@ function create(dir, id, name, cfg) {
         config_json.lib.www.id = config_json.lib.www.id || 'dummy_id';
         symlink  = !!config_json.lib.www.link;
 
-        // Make sure that the source www/ is not a direct ancestor of the target www/, or else we will recursively copy forever.
-        // To do this, we make sure that the shortest relative path from source-to-target must start by going up at least one directory.
-        var relative_path_from_source_to_target = path.relative(config_json.lib.www.url, www_dir);
-        var does_relative_path_go_up_at_least_one_dir = relative_path_from_source_to_target.split(path.sep)[0] == '..';
-        if (!does_relative_path_go_up_at_least_one_dir) {
+        // Make sure that the source www/ is not a direct ancestor of the
+        // target www/, or else we will recursively copy forever. To do this,
+        // we make sure that the shortest relative path from source-to-target
+        // must start by going up at least one directory or with a drive
+        // letter for Windows.
+        var rel_path = path.relative(config_json.lib.www.url, www_dir);
+        var goes_up = rel_path.split(path.sep)[0] == '..';
+
+        if (!(goes_up || rel_path[1] == ':')) {
             throw new CordovaError(
                 'Project dir "' +
                 dir +