Gruntfile.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. arch: grunt.option('arch') || 'x86_64',
  11. };
  12. config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
  13. // load plugins
  14. require('load-grunt-tasks')(grunt);
  15. // load task definitions
  16. grunt.loadTasks('tasks');
  17. // Utility function to load plugin settings into config
  18. function loadConfig(config,path) {
  19. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  20. var key = option.replace(/\.js$/,'');
  21. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  22. config[key] = config[key] || {};
  23. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  24. });
  25. // technically not required
  26. return config;
  27. }
  28. // Merge that object with what with whatever we have here
  29. loadConfig(config,'./tasks/options/');
  30. // pass the config to grunt
  31. grunt.initConfig(config);
  32. };