Gruntfile.js 1.54 KB
Newer Older
Spencer Alger committed
1
/* jshint node:true */
2 3
'use strict';
module.exports = function (grunt) {
4
  var os = require('os');
Spencer Alger committed
5
  var config = {
6
    pkg: grunt.file.readJSON('package.json'),
Rashid Khan committed
7
    baseDir: '.',
8
    srcDir: 'public',
9
    genDir: 'public_gen',
Spencer Alger committed
10 11
    destDir: 'dist',
    tempDir: 'tmp',
12
    platform: process.platform.replace('win32', 'windows'),
Spencer Alger committed
13 14
  };

15
  if (grunt.option('arch')) {
bergquist committed
16
    config.arch = grunt.option('arch');
17
  } else {
bergquist committed
18
    config.arch = os.arch();
19 20 21 22

    if (process.platform.match(/^win/)) {
      config.arch = process.env.hasOwnProperty('ProgramFiles(x86)') ? 'x64' : 'x86';
    }
23 24
  }

25
  config.coverage = grunt.option('coverage');
fg2it committed
26
  config.phjs = grunt.option('phjsToRelease');
27
  config.pkg.version = grunt.option('pkgVer') || config.pkg.version;
28

Torkel Ödegaard committed
29
  console.log('Version', config.pkg.version);
30

Rashid Khan committed
31 32
  // load plugins
  require('load-grunt-tasks')(grunt);
33

Rashid Khan committed
34
  // load task definitions
Torkel Ödegaard committed
35
  grunt.loadTasks('./scripts/grunt');
36

37 38
  // Utility function to load plugin settings into config
  function loadConfig(config,path) {
Rashid Khan committed
39
    require('glob').sync('*', {cwd: path}).forEach(function(option) {
40 41 42
      var key = option.replace(/\.js$/,'');
      // If key already exists, extend it. It is your responsibility to avoid naming collisions
      config[key] = config[key] || {};
43
      grunt.util._.extend(config[key], require(path + option)(config,grunt));
44
    });
45 46
    // technically not required
    return config;
Rashid Khan committed
47
  }
48

Rashid Khan committed
49
  // Merge that object with what with whatever we have here
Torkel Ödegaard committed
50
  loadConfig(config,'./scripts/grunt/options/');
51 52
  // pass the config to grunt
  grunt.initConfig(config);
Torkel Ödegaard committed
53
};