Gruntfile.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* jshint node:true */
  2. 'use strict';
  3. module.exports = function (grunt) {
  4. var config = {
  5. pkg: grunt.file.readJSON('package.json'),
  6. baseDir: '.',
  7. srcDir: 'src',
  8. destDir: 'dist',
  9. tempDir: 'tmp',
  10. docsDir: 'docs/',
  11. arch: grunt.option('arch') || 'x86_64',
  12. };
  13. config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
  14. // load plugins
  15. require('load-grunt-tasks')(grunt);
  16. // load task definitions
  17. grunt.loadTasks('tasks');
  18. // Utility function to load plugin settings into config
  19. function loadConfig(config,path) {
  20. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  21. var key = option.replace(/\.js$/,'');
  22. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  23. config[key] = config[key] || {};
  24. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  25. });
  26. // technically not required
  27. return config;
  28. }
  29. // Merge that object with what with whatever we have here
  30. loadConfig(config,'./tasks/options/');
  31. // pass the config to grunt
  32. grunt.initConfig(config);
  33. };