Skip to content

Commit

Permalink
Fix relative symlink paths (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
jswidler authored and ctalkington committed Oct 28, 2017
1 parent 3d0f974 commit 0bc4872
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ Archiver.prototype._updateQueueTaskWithStats = function(task, stats) {
task.source = new Buffer(0);
} else if (stats.isSymbolicLink() && this._moduleSupports('symlink')) {
var linkPath = fs.readlinkSync(task.filepath);
var dirName = path.dirname(task.filepath);
task.data.type = 'symlink';
task.data.linkname = path.relative(path.dirname(task.filepath), path.resolve(linkPath));
task.data.linkname = path.relative(dirName, path.resolve(dirName, linkPath));
task.data.sourceType = 'buffer';
task.source = new Buffer(0);
} else {
Expand Down
4 changes: 2 additions & 2 deletions test/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe('plugins', function() {
if (!win32) {
fs.chmodSync('test/fixtures/executable.sh', 0777);
fs.chmodSync('test/fixtures/directory/subdir/', 0755);
fs.symlinkSync('test/fixtures/directory/level0.txt', 'test/fixtures/directory/subdir/level0link.txt');
fs.symlinkSync('test/fixtures/directory/subdir/subsub/', 'test/fixtures/directory/subdir/subsublink');
fs.symlinkSync('../level0.txt', 'test/fixtures/directory/subdir/level0link.txt');
fs.symlinkSync('subsub/', 'test/fixtures/directory/subdir/subsublink');
} else {
fs.writeFileSync('test/fixtures/directory/subdir/level0link.txt', '../level0.txt');
fs.writeFileSync('test/fixtures/directory/subdir/subsublink', 'subsub');
Expand Down

0 comments on commit 0bc4872

Please sign in to comment.