diff --git a/Gruntfile.js b/Gruntfile.js index 07d56c92b7d..7412970b956 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,8 +26,21 @@ module.exports = function(grunt) { var path = require('path'), tasks = {}, - cwd = process.env.PWD || process.cwd(), - inAMD = path.basename(cwd) == 'amd'; + cwd = process.env.PWD || process.cwd(); + + // Windows users can't run grunt in a subdirectory, so allow them to set + // the root by passing --root=path/to/dir. + if (grunt.option('root')) { + var root = grunt.option('root'); + if (grunt.file.exists(__dirname, root)) { + cwd = path.join(__dirname, root); + grunt.log.ok('Setting root to '+cwd); + } else { + grunt.fail.fatal('Setting root to '+root+' failed - path does not exist'); + } + } + + var inAMD = path.basename(cwd) == 'amd'; // Globbing pattern for matching all AMD JS source files. var amdSrc = [inAMD ? cwd + '/src/*.js' : '**/amd/src/*.js'];