Gruntfile.js 1.5 KB

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