Gruntfile.js 1.6 KB

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