Gruntfile.js 1.1 KB

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