grafana/Gruntfile.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

'use strict';
module.exports = function(grunt) {
var os = require('os');
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: '.',
2015-03-29 05:57:28 -05:00
srcDir: 'public',
2015-09-10 04:26:40 -05:00
genDir: 'public_gen',
2013-09-13 15:52:13 -05:00
destDir: 'dist',
tempDir: 'tmp',
platform: process.platform.replace('win32', 'windows'),
enterprise: false,
libc: null,
2013-09-13 15:52:13 -05:00
};
if (grunt.option('platform')) {
config.platform = grunt.option('platform');
}
if (grunt.option('enterprise')) {
config.enterprise = true;
}
if (grunt.option('arch')) {
2016-10-17 08:19:00 -05:00
config.arch = grunt.option('arch');
} else {
2016-10-17 08:19:00 -05:00
config.arch = os.arch();
if (process.platform.match(/^win/)) {
config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
}
}
if (grunt.option('libc')) {
config.libc = grunt.option('libc');
}
2015-03-04 00:09:59 -06:00
config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
2016-03-30 14:02:44 -05:00
console.log('Version', config.pkg.version);
2015-03-04 00:09:59 -06:00
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('./scripts/grunt');
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) {
require('glob')
.sync('*', { cwd: path })
.forEach(function(option) {
var key = option.replace(/\.js$/, '');
// If key already exists, extend it. It is your responsibility to avoid naming collisions
config[key] = config[key] || {};
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
loadConfig(config, './scripts/grunt/options/');
// pass the config to grunt
grunt.initConfig(config);
2014-08-11 09:37:31 -05:00
};