Gruntfile.js 1.6 KB

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