From 0652305f1b79dfdc85a9bd0f2e78ca1e9ae795f5 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Mon, 11 Apr 2022 11:09:01 -0400 Subject: [PATCH] Fix symlink test --- lib/grunt/file.js | 2 -- test/grunt/file_test.js | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/grunt/file.js b/lib/grunt/file.js index ce268d04..b5f51a22 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -459,14 +459,12 @@ file._isSymbolicLink = function() { file._copySymbolicLink = function(srcpath, destpath) { var destdir = path.join(destpath, '..'); - var fileBase = path.basename(srcpath); // Use the correct relative path for the symlink if (!grunt.file.isPathAbsolute(srcpath)) { srcpath = path.relative(destdir, srcpath) || '.'; } file.mkdir(destdir); var mode = grunt.file.isDir(srcpath) ? 'dir' : 'file'; - var destpath = path.join(destpath, fileBase); if (fs.existsSync(destpath)) { // skip symlink if file already exists return; diff --git a/test/grunt/file_test.js b/test/grunt/file_test.js index b24870c7..0448f305 100644 --- a/test/grunt/file_test.js +++ b/test/grunt/file_test.js @@ -899,7 +899,7 @@ exports.file = { fs.symlinkSync(path.resolve('test/fixtures/octocat.png'), path.join(srcfile.path, 'octocat.png'), 'file'); // test symlink copy for files var destdir = new Tempdir(); - grunt.file.copy(path.join(srcfile.path, 'octocat.png'), destdir.path); + grunt.file.copy(path.join(srcfile.path, 'octocat.png'), path.join(destdir.path, 'octocat.png')); test.ok(fs.lstatSync(path.join(srcfile.path, 'octocat.png')).isSymbolicLink()); test.ok(fs.lstatSync(path.join(destdir.path, 'octocat.png')).isSymbolicLink()); @@ -908,9 +908,10 @@ exports.file = { var destdir = new Tempdir(); var fixtures = path.resolve('test/fixtures'); var symlinkSource = path.join(srcdir.path, path.basename(fixtures)); + var destSource = path.join(destdir.path, path.basename(fixtures)); fs.symlinkSync(fixtures, symlinkSource, 'dir'); - grunt.file.copy(symlinkSource, destdir.path); + grunt.file.copy(symlinkSource, destSource); test.ok(fs.lstatSync(symlinkSource).isSymbolicLink()); test.ok(fs.lstatSync(path.join(destdir.path, path.basename(fixtures))).isSymbolicLink()); test.done();