Repository: cordova-lib
Updated Branches:
  refs/heads/master 9a155bd7f -> c1598fb48


allow recursive folder copy skipping whatever .. was


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

Branch: refs/heads/master
Commit: 43a63863247ecf9fe098f6b1e8416e658b2fc729
Parents: 9a155bd
Author: Jesse MacFadyen <[email protected]>
Authored: Sat Jan 23 19:52:44 2016 -0800
Committer: Steve Gill <[email protected]>
Committed: Sun Jan 24 21:09:28 2016 -0800

----------------------------------------------------------------------
 cordova-lib/src/plugman/fetch.js | 32 +++++++++++++++++++++++++++++---
 1 file changed, 29 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/43a63863/cordova-lib/src/plugman/fetch.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/plugman/fetch.js b/cordova-lib/src/plugman/fetch.js
index 3ba123b..dc8e28c 100644
--- a/cordova-lib/src/plugman/fetch.js
+++ b/cordova-lib/src/plugman/fetch.js
@@ -277,12 +277,38 @@ function copyPlugin(pinfo, plugins_dir, link) {
         return altDest;
     }
 
+    shell.rm('-rf', dest);
+
     if(!link && dest.indexOf(path.resolve(plugin_dir)) === 0) {
-        events.emit('verbose', 'Copy plugin destination is child of src. 
Forcing --link mode.');
-        link = true;
+        
+        if(/^win/.test(process.platform)) {
+            /*
+                [CB-10423]
+                This is a special case. On windows we cannot create a symlink 
unless we are run as admin
+                The error that we have is because src contains dest, so we end 
up with a recursive folder explosion
+                This code avoids copy the one folder that will explode, and 
allows plugins to contain a demo project
+                and to install the plugin via `cordova plugin add ../`
+            */
+            var resolvedSrcPath = path.resolve(plugin_dir);
+            var filenames = fs.readdirSync(resolvedSrcPath);
+            var relPath = path.relative(resolvedSrcPath,dest);
+            var relativeRootFolder = relPath.split('\\')[0];
+            filenames.splice(filenames.indexOf(relativeRootFolder),1);
+            shell.mkdir('-p', dest);
+            events.emit('verbose', 'Copying plugin "' + resolvedSrcPath + '" 
=> "' + dest + '"');
+            events.emit('verbose', 'Skipping folder "' + relativeRootFolder + 
'"');
+            
+            filenames.forEach(function(elem) {
+                shell.cp('-R', path.join(resolvedSrcPath,elem) , dest);
+            });
+            return dest;
+        }
+        else {
+            events.emit('verbose', 'Copy plugin destination is child of src. 
Forcing --link mode.');
+            link = true;
+        }
     }
 
-    shell.rm('-rf', dest);
     if (link) {
         var isRelativePath = plugin_dir.charAt(1) != ':' && 
plugin_dir.charAt(0) != path.sep;
         var fixedPath = isRelativePath ? path.join(path.relative(plugins_dir, 
process.env.PWD || process.cwd()), plugin_dir) : plugin_dir;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to