Skip to content

Commit ad22608

Browse files
authored
Merge pull request #1742 from gruntjs/update-symlink-test
Fix symlink test
2 parents a7ab0a8 + 0652305 commit ad22608

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

lib/grunt/file.js

-2
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,12 @@ file._isSymbolicLink = function() {
459459

460460
file._copySymbolicLink = function(srcpath, destpath) {
461461
var destdir = path.join(destpath, '..');
462-
var fileBase = path.basename(srcpath);
463462
// Use the correct relative path for the symlink
464463
if (!grunt.file.isPathAbsolute(srcpath)) {
465464
srcpath = path.relative(destdir, srcpath) || '.';
466465
}
467466
file.mkdir(destdir);
468467
var mode = grunt.file.isDir(srcpath) ? 'dir' : 'file';
469-
var destpath = path.join(destpath, fileBase);
470468
if (fs.existsSync(destpath)) {
471469
// skip symlink if file already exists
472470
return;

test/grunt/file_test.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ exports.file = {
899899
fs.symlinkSync(path.resolve('test/fixtures/octocat.png'), path.join(srcfile.path, 'octocat.png'), 'file');
900900
// test symlink copy for files
901901
var destdir = new Tempdir();
902-
grunt.file.copy(path.join(srcfile.path, 'octocat.png'), destdir.path);
902+
grunt.file.copy(path.join(srcfile.path, 'octocat.png'), path.join(destdir.path, 'octocat.png'));
903903
test.ok(fs.lstatSync(path.join(srcfile.path, 'octocat.png')).isSymbolicLink());
904904
test.ok(fs.lstatSync(path.join(destdir.path, 'octocat.png')).isSymbolicLink());
905905

@@ -908,9 +908,10 @@ exports.file = {
908908
var destdir = new Tempdir();
909909
var fixtures = path.resolve('test/fixtures');
910910
var symlinkSource = path.join(srcdir.path, path.basename(fixtures));
911+
var destSource = path.join(destdir.path, path.basename(fixtures));
911912
fs.symlinkSync(fixtures, symlinkSource, 'dir');
912913

913-
grunt.file.copy(symlinkSource, destdir.path);
914+
grunt.file.copy(symlinkSource, destSource);
914915
test.ok(fs.lstatSync(symlinkSource).isSymbolicLink());
915916
test.ok(fs.lstatSync(path.join(destdir.path, path.basename(fixtures))).isSymbolicLink());
916917
test.done();

0 commit comments

Comments
 (0)