Gruntfile.js 1.3 KB

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