From 679c0ae670cfa25c206ed7d2967cac71b71187ba Mon Sep 17 00:00:00 2001 From: Jmeas Date: Thu, 13 Mar 2014 13:08:02 -0400 Subject: [PATCH] Some starting work --- lib/grunt/file.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/grunt/file.js b/lib/grunt/file.js index 461c62b77..22eefa368 100644 --- a/lib/grunt/file.js +++ b/lib/grunt/file.js @@ -305,6 +305,19 @@ file.copy = function(srcpath, destpath, options) { // If the file will be processed, use the encoding as-specified. Otherwise, // use an encoding of null to force the file to be read/written as a Buffer. var readWriteOptions = process ? options : {encoding: null}; + // Copy symlinks as symlinks + var isLink = fs.lstatSync( srcpath ).isSymbolicLink(); + if ( isLink ) { + var destdir = path.join( destpath, '..' ); + // 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'; + fs.symlinkSync(srcpath, destpath, mode); + return; + } // Actually read the file. var contents = file.read(srcpath, readWriteOptions); if (process) {