From 8127f39eee6ee315483e5ab8bfdb263beea02ad4 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Thu, 28 Jan 2016 14:55:56 +0000 Subject: [PATCH 1/2] 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. --- Gruntfile.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 3dd3ef01bfb..98a59cfd158 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -26,8 +26,21 @@ module.exports = function(grunt) { var path = require('path'), fs = require('fs'), 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'; // Project configuration. grunt.initConfig({ From 5a906c572782aad8ebc728925414c9687129d058 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 2 Feb 2016 12:00:24 +0000 Subject: [PATCH 2/2] MDL-50115 grunt: add missing jshint configuration The gruntfile isn't a normal browser environment --- Gruntfile.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Gruntfile.js b/Gruntfile.js index 98a59cfd158..2d13f0d87b5 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,6 +12,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/* jshint node: true, browser: false */ /** * @copyright 2014 Andrew Nicols