grafana/Gruntfile.js

45 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-09-14 04:52:13 +08:00
/* jshint node:true */
'use strict';
module.exports = function (grunt) {
var os = require('os');
2013-09-14 04:52:13 +08:00
var config = {
pkg: grunt.file.readJSON('package.json'),
2013-11-15 12:29:41 +08:00
baseDir: '.',
2015-03-29 18:57:28 +08:00
srcDir: 'public',
2015-09-10 17:26:40 +08:00
genDir: 'public_gen',
2013-09-14 04:52:13 +08:00
destDir: 'dist',
tempDir: 'tmp',
arch: os.arch(),
platform: process.platform.replace('win32', 'windows'),
2013-09-14 04:52:13 +08:00
};
if (process.platform.match(/^win/)) {
config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
}
2015-03-04 14:09:59 +08:00
config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
2013-11-15 07:07:14 +08:00
// load plugins
require('load-grunt-tasks')(grunt);
2013-11-15 07:07:14 +08:00
// load task definitions
grunt.loadTasks('tasks');
2013-10-18 06:33:43 +08:00
2013-11-15 11:30:28 +08:00
// Utility function to load plugin settings into config
function loadConfig(config,path) {
2013-11-15 07:07:14 +08:00
require('glob').sync('*', {cwd: path}).forEach(function(option) {
2013-11-15 11:30:28 +08: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-16 00:44:06 +08:00
grunt.util._.extend(config[key], require(path + option)(config,grunt));
});
2013-11-15 11:30:28 +08:00
// technically not required
return config;
2013-11-15 07:07:14 +08:00
}
2013-11-15 07:07:14 +08:00
// Merge that object with what with whatever we have here
2013-11-15 11:30:28 +08:00
loadConfig(config,'./tasks/options/');
// pass the config to grunt
grunt.initConfig(config);
2014-08-11 22:37:31 +08:00
};