From 0c7701dc573ef125a00525c61461186479010f64 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 30 May 2013 18:00:14 -0700 Subject: [PATCH] Copy files consistently with perms --- Gruntfile.coffee | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Gruntfile.coffee b/Gruntfile.coffee index 2cc73b2ad..6b3003773 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -37,21 +37,23 @@ module.exports = (grunt) -> callback(error) cp = (source, destination, {filter}={}) -> + copyFile = (source, destination) -> + if grunt.file.isLink(source) + grunt.file.mkdir(path.dirname(destination)) + fs.symlinkSync(fs.readlinkSync(source), destination) + else + grunt.file.copy(source, destination) + + if grunt.file.exists(destination) + fs.chmodSync(destination, fs.statSync(source).mode) + if grunt.file.isDir(source) grunt.file.recurse source, (sourcePath, rootDirectory, subDirectory='', filename) -> - return if filter?.test(sourcePath) - - destinationPath = path.join(destination, subDirectory, filename) - if grunt.file.isLink(sourcePath) - grunt.file.mkdir(path.dirname(destinationPath)) - fs.symlinkSync(fs.readlinkSync(sourcePath), destinationPath) - else - grunt.file.copy(sourcePath, destinationPath) - - if grunt.file.exists(destinationPath) - fs.chmodSync(destinationPath, fs.statSync(sourcePath).mode) + unless filter?.test(sourcePath) + copyFile(sourcePath, path.join(destination, subDirectory, filename)) else - grunt.file.copy(source, destination) + copyFile(source, destination) + grunt.log.writeln("Copied #{source.cyan} to #{destination.cyan}.") mkdir = (args...) -> grunt.file.mkdir(args...)