Skip to content
Permalink
Browse files
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
  • Loading branch information
oliversalzburg authored and raphinesse committed Sep 25, 2018
1 parent 63b26e6 commit 3079853c0ac2a60c7c38db87fc1996ab3cf1b9b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
@@ -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);
});
});
@@ -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;
}

0 comments on commit 3079853

Please sign in to comment.