2018-07-21 21:00:08 +02:00
|
|
|
/* eslint-disable more/no-then, no-console */
|
2014-11-23 04:36:52 +01:00
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
module.exports = grunt => {
|
2014-10-30 02:32:29 +01:00
|
|
|
grunt.initConfig({
|
2014-11-23 04:36:52 +01:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
2018-04-27 23:25:04 +02:00
|
|
|
gitinfo: {}, // to be populated by grunt gitinfo
|
2014-11-23 04:36:52 +01:00
|
|
|
});
|
|
|
|
|
2018-07-07 02:48:14 +02:00
|
|
|
Object.keys(grunt.config.get('pkg').devDependencies).forEach(key => {
|
2018-04-27 23:25:04 +02:00
|
|
|
if (/^grunt(?!(-cli)?$)/.test(key)) {
|
|
|
|
// ignore grunt and grunt-cli
|
2014-11-23 04:36:52 +01:00
|
|
|
grunt.loadNpmTasks(key);
|
2014-10-31 01:57:37 +01:00
|
|
|
}
|
2014-10-30 02:32:29 +01:00
|
|
|
});
|
|
|
|
|
2019-03-01 07:10:20 +01:00
|
|
|
function updateLocalConfig(update) {
|
2022-03-22 00:42:15 +01:00
|
|
|
const environment = process.env.SIGNAL_ENV || 'production';
|
2019-03-01 07:10:20 +01:00
|
|
|
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 });
|
2017-04-13 19:52:12 +02:00
|
|
|
});
|
|
|
|
|
2021-12-14 05:15:12 +01:00
|
|
|
grunt.registerTask('date', ['gitinfo']);
|
2022-08-26 03:35:19 +02:00
|
|
|
grunt.registerTask('default', ['date', 'getCommitHash']);
|
2014-10-30 02:32:29 +01:00
|
|
|
};
|