Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/grunt/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions test/grunt/file_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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();
Expand Down