From 433f91b78df99d83daa6f56a5505ead743627c30 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Mon, 11 Apr 2022 11:38:22 -0400 Subject: [PATCH 1/3] Clean up link handling --- lib/grunt/file.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/grunt/file.js b/lib/grunt/file.js index b5f51a22..604736cd 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -294,7 +294,12 @@ file.write = function(filepath, contents, options) { // processing content, writing output. // Handles symlinks by coping them as files or directories. file.copy = function copy(srcpath, destpath, options) { - if (file._isSymbolicLink(srcpath)) { + if (file.isLink(destpath)) { + // in case destpath is a symlink, avoid following the symlink, instead overwrite it later + fs.unlinkSync(destpath); + } + + if (file.isLink(srcpath)) { file._copySymbolicLink(srcpath, destpath); } else if (file.isDir(srcpath)) { // Copy a directory, recursively. @@ -452,11 +457,6 @@ file.isPathCwd = function() { } }; -file._isSymbolicLink = function() { - var filepath = path.join.apply(path, arguments); - return fs.lstatSync(filepath).isSymbolicLink(); -}; - file._copySymbolicLink = function(srcpath, destpath) { var destdir = path.join(destpath, '..'); // Use the correct relative path for the symlink From 7f15fd5ad9fb33ca0fe4680af7bce84d69deb673 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Tue, 12 Apr 2022 07:57:34 -0400 Subject: [PATCH 2/3] Update Changelog --- CHANGELOG | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index efd15d36..bd1848ca 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +v1.5.2 + date: 2022-04-12 + changes: + - Unlink symlinks when copy destination is a symlink. +v1.5.1 + date: 2022-04-11 + changes: + - Fixed symlink destination handling. v1.5.0 date: 2022-04-10 changes: From ac667b24cabfff77cf769f9dbf9ddba9576b3dc2 Mon Sep 17 00:00:00 2001 From: Vlad Filippov Date: Tue, 12 Apr 2022 07:58:07 -0400 Subject: [PATCH 3/3] 1.5.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 78c1b291..18fe7823 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt", "description": "The JavaScript Task Runner", - "version": "1.5.1", + "version": "1.5.2", "author": "Grunt Development Team (https://gruntjs.com/development-team)", "homepage": "https://gruntjs.com/", "repository": "https://github.com/gruntjs/grunt.git",