Skip to content

Commit b0ec6e1

Browse files
authored
Merge pull request #1743 from gruntjs/cleanup-link
Clean up link handling
2 parents d5969ec + 433f91b commit b0ec6e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/grunt/file.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,12 @@ file.write = function(filepath, contents, options) {
294294
// processing content, writing output.
295295
// Handles symlinks by coping them as files or directories.
296296
file.copy = function copy(srcpath, destpath, options) {
297-
if (file._isSymbolicLink(srcpath)) {
297+
if (file.isLink(destpath)) {
298+
// in case destpath is a symlink, avoid following the symlink, instead overwrite it later
299+
fs.unlinkSync(destpath);
300+
}
301+
302+
if (file.isLink(srcpath)) {
298303
file._copySymbolicLink(srcpath, destpath);
299304
} else if (file.isDir(srcpath)) {
300305
// Copy a directory, recursively.
@@ -452,11 +457,6 @@ file.isPathCwd = function() {
452457
}
453458
};
454459

455-
file._isSymbolicLink = function() {
456-
var filepath = path.join.apply(path, arguments);
457-
return fs.lstatSync(filepath).isSymbolicLink();
458-
};
459-
460460
file._copySymbolicLink = function(srcpath, destpath) {
461461
var destdir = path.join(destpath, '..');
462462
// Use the correct relative path for the symlink

0 commit comments

Comments
 (0)