Gruntfile.js 1.3 KB

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