grafana/Gruntfile.js

54 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-09-13 15:52:13 -05:00
/* jshint node:true */
'use strict';
module.exports = function (grunt) {
2013-09-13 15:52:13 -05:00
var config = {
pkg: grunt.file.readJSON('package.json'),
2013-11-14 22:29:41 -06:00
baseDir: '.',
2013-09-13 15:52:13 -05:00
srcDir: 'src',
destDir: 'dist',
tempDir: 'tmp',
2013-12-02 13:43:39 -06:00
docsDir: 'docs/'
2013-09-13 15:52:13 -05:00
};
config.mode = grunt.option('mode') || 'backend';
config.modeOptions = {
2015-01-04 10:51:48 -06:00
zipSuffix: '',
requirejs: {
paths: { config: '../config.sample' },
excludeConfig: true,
}
};
if (config.mode === 'backend') {
2015-01-04 10:51:48 -06:00
grunt.log.writeln('Setting backend build mode');
config.modeOptions.zipSuffix = '-backend';
2015-01-05 04:04:58 -06:00
config.modeOptions.requirejs.paths = {};
config.modeOptions.requirejs.excludeConfig = false;
}
2013-11-14 17:07:14 -06:00
// load plugins
require('load-grunt-tasks')(grunt);
2013-11-14 17:07:14 -06:00
// load task definitions
grunt.loadTasks('tasks');
2013-10-17 17:33:43 -05:00
2013-11-14 21:30:28 -06:00
// Utility function to load plugin settings into config
function loadConfig(config,path) {
2013-11-14 17:07:14 -06:00
require('glob').sync('*', {cwd: path}).forEach(function(option) {
2013-11-14 21:30:28 -06:00
var key = option.replace(/\.js$/,'');
// If key already exists, extend it. It is your responsibility to avoid naming collisions
config[key] = config[key] || {};
2013-11-15 10:44:06 -06:00
grunt.util._.extend(config[key], require(path + option)(config,grunt));
});
2013-11-14 21:30:28 -06:00
// technically not required
return config;
2013-11-14 17:07:14 -06:00
}
2013-11-14 17:07:14 -06:00
// Merge that object with what with whatever we have here
2013-11-14 21:30:28 -06:00
loadConfig(config,'./tasks/options/');
// pass the config to grunt
grunt.initConfig(config);
2014-08-11 09:37:31 -05:00
};