Gruntfile.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* jshint node:true */
  2. 'use strict';
  3. module.exports = function (grunt) {
  4. var os = require('os');
  5. var config = {
  6. pkg: grunt.file.readJSON('package.json'),
  7. baseDir: '.',
  8. srcDir: 'public',
  9. genDir: 'public_gen',
  10. destDir: 'dist',
  11. tempDir: 'tmp',
  12. arch: os.arch(),
  13. platform: process.platform.replace('win32', 'windows'),
  14. };
  15. if (process.platform.match(/^win/)) {
  16. config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
  17. }
  18. config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
  19. console.log('Version', config.pkg.version);
  20. // load plugins
  21. require('load-grunt-tasks')(grunt);
  22. // load task definitions
  23. grunt.loadTasks('tasks');
  24. // Utility function to load plugin settings into config
  25. function loadConfig(config,path) {
  26. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  27. var key = option.replace(/\.js$/,'');
  28. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  29. config[key] = config[key] || {};
  30. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  31. });
  32. // technically not required
  33. return config;
  34. }
  35. // Merge that object with what with whatever we have here
  36. loadConfig(config,'./tasks/options/');
  37. // pass the config to grunt
  38. grunt.initConfig(config);
  39. };