Gruntfile.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. platform: process.platform.replace('win32', 'windows'),
  13. };
  14. if (process.platform.match(/^win/)) {
  15. config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
  16. }
  17. config.arch = grunt.option('arch') || os.arch();
  18. config.phjs = grunt.option('phjsToRelease');
  19. config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
  20. console.log('Version', config.pkg.version);
  21. // load plugins
  22. require('load-grunt-tasks')(grunt);
  23. // load task definitions
  24. grunt.loadTasks('tasks');
  25. // Utility function to load plugin settings into config
  26. function loadConfig(config,path) {
  27. require('glob').sync('*', {cwd: path}).forEach(function(option) {
  28. var key = option.replace(/\.js$/,'');
  29. // If key already exists, extend it. It is your responsibility to avoid naming collisions
  30. config[key] = config[key] || {};
  31. grunt.util._.extend(config[key], require(path + option)(config,grunt));
  32. });
  33. // technically not required
  34. return config;
  35. }
  36. // Merge that object with what with whatever we have here
  37. loadConfig(config,'./tasks/options/');
  38. // pass the config to grunt
  39. grunt.initConfig(config);
  40. };