mirror of
https://github.com/moodle/moodle.git
synced 2025-08-02 23:59:41 +02:00
MDL-50115 grunt: provide a --root option to set base path
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.
This commit is contained in:
parent
9d5d9c64ff
commit
00cceb7fba
1 changed files with 15 additions and 2 deletions
17
Gruntfile.js
17
Gruntfile.js
|
@ -26,8 +26,21 @@
|
||||||
module.exports = function(grunt) {
|
module.exports = function(grunt) {
|
||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
tasks = {},
|
tasks = {},
|
||||||
cwd = process.env.PWD || process.cwd(),
|
cwd = process.env.PWD || process.cwd();
|
||||||
inAMD = path.basename(cwd) == 'amd';
|
|
||||||
|
// 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.
|
// Globbing pattern for matching all AMD JS source files.
|
||||||
var amdSrc = [inAMD ? cwd + '/src/*.js' : '**/amd/src/*.js'];
|
var amdSrc = [inAMD ? cwd + '/src/*.js' : '**/amd/src/*.js'];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue