forked from bmbrands/moodle-theme_elegance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
60 lines (49 loc) · 1.72 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module.exports = function(grunt) {
// Import modules.
var path = require('path');
// Theme Bootstrap constants.
var LESSDIR = 'less',
THEMEDIR = path.basename(path.resolve('.'));
// PHP strings for exec task.
var moodleroot = path.dirname(path.dirname(__dirname)),
configfile = '',
decachephp = '',
dirrootopt = grunt.option('dirroot') || process.env.MOODLE_DIR || '';
// Allow user to explicitly define Moodle root dir.
if ('' !== dirrootopt) {
moodleroot = path.resolve(dirrootopt);
}
configfile = path.join(moodleroot, 'config.php');
decachephp += 'define(\'CLI_SCRIPT\', true);';
decachephp += 'require(\'' + configfile + '\');';
decachephp += 'theme_reset_all_caches();';
grunt.initConfig({
exec: {
decache: {
cmd: 'php -r "' + decachephp + '"',
callback: function(error, stdout, stderror) {
// exec will output error messages
// just add one to confirm success.
if (!error) {
grunt.log.writeln("Moodle theme cache reset.");
}
}
}
},
watch: {
// Watch for any changes to less files and compile.
files: ["less/**/*.less"],
tasks: ["decache"],
options: {
spawn: false,
livereload: true
}
}
});
// Load contrib tasks.
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-exec");
// Register tasks.
grunt.registerTask("default", ["watch"]);
grunt.registerTask("decache", ["exec:decache"]);
};