-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
73 lines (65 loc) · 1.7 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
62
63
64
65
66
67
68
69
70
71
72
73
const importOnce = require('node-sass-import-once');
const sass = require('node-sass');
/* eslint-disable more/no-then, no-console */
module.exports = grunt => {
grunt.loadNpmTasks('grunt-sass');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
options: {
implementation: sass,
sourceMap: true,
importer: importOnce,
},
dist: {
files: {
'stylesheets/manifest.css': 'stylesheets/manifest.scss',
},
},
},
exec: {
transpile: {
cmd: 'yarn transpile',
},
'protobuf': {
cmd: 'yarn protobuf',
},
},
gitinfo: {}, // to be populated by grunt gitinfo
});
Object.keys(grunt.config.get('pkg').devDependencies).forEach(key => {
if (/^grunt(?!(-cli)?$)/.test(key)) {
// ignore grunt and grunt-cli
grunt.loadNpmTasks(key);
}
});
function updateLocalConfig(update) {
const environment = process.env.SIGNAL_ENV || 'production';
const configPath = `config/local-${environment}.json`;
let localConfig;
try {
localConfig = grunt.file.readJSON(configPath);
} catch (e) {
//
}
localConfig = {
...localConfig,
...update,
};
grunt.file.write(configPath, `${JSON.stringify(localConfig)}\n`);
}
grunt.registerTask('getCommitHash', () => {
grunt.task.requires('gitinfo');
const gitinfo = grunt.config.get('gitinfo');
const hash = gitinfo.local.branch.current.SHA;
updateLocalConfig({ commitHash: hash });
});
grunt.registerTask('date', ['gitinfo']);
grunt.registerTask('default', [
'exec:protobuf',
'sass',
'exec:transpile',
'date',
'getCommitHash',
]);
};