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: 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 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",