You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2018/09/25 11:06:21 UTC

[cordova-lib] branch master updated: Dereference possible symlinks when copying plugin (#705)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-lib.git


The following commit(s) were added to refs/heads/master by this push:
     new 3079853  Dereference possible symlinks when copying plugin (#705)
3079853 is described below

commit 3079853c0ac2a60c7c38db87fc1996ab3cf1b9b8
Author: Oliver Salzburg <ol...@gmail.com>
AuthorDate: Tue Sep 25 13:06:17 2018 +0200

    Dereference possible symlinks when copying plugin (#705)
    
    When `npm install`ing a local plugin, npm will create a symlink to the source. When we then attempt to copy that symlink, the result will be invalid on Windows OS. Thus, we need to dereference the link/junction and create a proper copy.
    
    Fixes #700
    Fixes #704
---
 integration-tests/plugman_fetch.spec.js | 6 +++---
 src/plugman/fetch.js                    | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/integration-tests/plugman_fetch.spec.js b/integration-tests/plugman_fetch.spec.js
index e16a337..81ef6aa 100644
--- a/integration-tests/plugman_fetch.spec.js
+++ b/integration-tests/plugman_fetch.spec.js
@@ -85,12 +85,12 @@ describe('fetch', function () {
 
         it('Test 001 : should copy locally-available plugin to plugins directory', function () {
             return fetch(test_plugin, temp).then(function () {
-                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_plugin), path.join(temp, test_plugin_id));
+                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_plugin), path.join(temp, test_plugin_id), jasmine.objectContaining({dereference: true}));
             });
         });
         it('Test 002 : should copy locally-available plugin to plugins directory when adding a plugin with searchpath argument', function () {
             return fetch(test_plugin_id, temp, { searchpath: test_plugin_searchpath }).then(function () {
-                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_plugin), path.join(temp, test_plugin_id));
+                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_plugin), path.join(temp, test_plugin_id), jasmine.objectContaining({dereference: true}));
             });
         });
         it('Test 003 : should create a symlink if used with `link` param', function () {
@@ -129,7 +129,7 @@ describe('fetch', function () {
         });
         it('Test 027 : should copy locally-available plugin to plugins directory', function () {
             return fetch(test_pkgjson_plugin, temp).then(function () {
-                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_pkgjson_plugin), path.join(temp, 'pkgjson-test-plugin'));
+                expect(fs.copySync).toHaveBeenCalledWith(path.join(test_pkgjson_plugin), path.join(temp, 'pkgjson-test-plugin'), jasmine.objectContaining({dereference: true}));
                 expect(fetchCalls).toBe(1);
             });
         });
diff --git a/src/plugman/fetch.js b/src/plugman/fetch.js
index d52bae7..86d3ea3 100644
--- a/src/plugman/fetch.js
+++ b/src/plugman/fetch.js
@@ -289,7 +289,7 @@ function copyPlugin (pinfo, plugins_dir, link) {
         fs.symlinkSync(fixedPath, dest, 'junction');
     } else {
         events.emit('verbose', 'Copying plugin "' + plugin_dir + '" => "' + dest + '"');
-        fs.copySync(plugin_dir, dest);
+        fs.copySync(plugin_dir, dest, {dereference: true});
     }
     return dest;
 }


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