From 614edcc8badb4713701ce3e87f74df97f93feb79 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Thu, 11 Sep 2014 00:25:39 -0400 Subject: [PATCH] Apply fixwhitespace task to the current directory --- Gruntfile.js | 8 ++++++-- README.md | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 8d66413..5a707ff 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,7 +12,7 @@ module.exports = function(grunt) { }, trimtrailingspaces: { main: { - src: ['/tmp/test/*'], + src: ['<%= cwd %>/**/*'], options: { filter: 'isFile', encoding: 'utf8', @@ -25,6 +25,10 @@ module.exports = function(grunt) { grunt.loadNpmTasks('grunt-trimtrailingspaces'); grunt.loadNpmTasks('grunt-contrib-watch'); + var cwd = grunt.option('cwd'); grunt.registerTask('default', []); - grunt.registerTask('fixwhitespace', ['trimtrailingspaces']); + grunt.registerTask('fixwhitespace', function() { + grunt.config.set('cwd', cwd); + grunt.task.run('trimtrailingspaces'); + }); }; diff --git a/README.md b/README.md index e6ab934..791b3cb 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,14 @@ # Global Runners +## Setup + +Add an alias to your rc file + +```alias rt="grunt --gruntfile ~/grunt-test/Gruntfile.js -cwd=`pwd`"``` + ## Usage -grunt --gruntfile ~/grunt-test/Gruntfile.js TASK - -alias rt="grunt --gruntfile ~/grunt-test/Gruntfile.js TASK" +```rt TASK_NAME``` ## Tasks