Skip to content

Commit

Permalink
MDL-50115 grunt: provide a --root option to set base path
Browse files Browse the repository at this point in the history
Windows users are not able to run grunt on a subpath due to platform
restrictions. So we provide this option to provide a workaround for that.

Thanks to Ty Delean who proposed this idea.
  • Loading branch information
danpoltawski committed Feb 4, 2016
1 parent 9d5d9c6 commit 00cceb7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down

0 comments on commit 00cceb7

Please sign in to comment.