-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
61 lines (53 loc) · 1.32 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
61
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
function reloadChromeExtensionsTab(err, stdout, stderr, cb) {
if (err) {
grunt.log.writeln("Not reloading Chrome extensions tab");
cb();
return;
}
console.log("Reloading Chrome extensions tab");
var exec = require('child_process').exec;
var extensionsTabMatches = stdout.match(/\[\d{1,5}:(\d{1,5})\] Extensions/);
if (extensionsTabMatches) {
extensionsTabID = extensionsTabMatches[1];
exec('chrome-cli reload -t ' + extensionsTabID, function (err, stdout, stderr) {
cb();
});
}
else {
exec('chrome-cli open chrome://extensions && chrome-cli reload', function (err, stdout, stderr) {
cb();
});
}
}
// On macOS, reload Chrome extensions tab
var watchTasks = ['default'];
if (process.platform == 'darwin') {
watchTasks.push('shell:reloadChromeExtensionsTab');
}
grunt.initConfig({
watch: {
scripts: {
files: ['manifest.json', 'src/**', '!**/#*'],
tasks: watchTasks
}
},
shell: {
build: {
command: './build -p b -d',
options: {
stdout: true
}
},
reloadChromeExtensionsTab: {
command: 'chrome-cli list tabs',
options: {
callback: reloadChromeExtensionsTab,
stdout: false
}
}
}
});
grunt.registerTask('default', ['shell:build']);
};