State variable dependencies explicitly

pull/1288/head
Nicklas Gummesson 10 years ago
parent 982bf472c1
commit bf1d14fc97

1
.gitignore vendored

@ -23,6 +23,7 @@ config/database.yml
.idea/*
config/app_config.yml
config/redis.conf
config/grunt_production.json
src/
spec/support/data/failed_remote/*
*.swp

@ -14,7 +14,12 @@
var ASSETS_DIR = './public/assets/<%= pkg.version %>';
// use grunt --environment production
var env = grunt.option('environment') || 'development';
var env = './config/grunt_' + (grunt.option('environment') || 'development') + '.json';
if (grunt.file.exists(env)) {
env = grunt.file.readJSON(env)
} else {
throw grunt.util.error(env +' file is missing! See '+ env +'.sample for how it should look like');
}
var aws = {};
if (grunt.file.exists('./lib/build/grunt-aws.json')) {
@ -25,7 +30,7 @@
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
aws: aws,
env: grunt.file.readJSON("./lib/build/config/" + env + ".json"),
env: env,
gitrev: exec('git rev-parse HEAD', { silent:true }).output.replace('\n', ''),
assets_dir: ASSETS_DIR,
@ -63,7 +68,7 @@
uglify: require('./lib/build/tasks/uglify.js').task(),
browserify: require('./lib/build/tasks/browserify.js').task(grunt)
browserify: require('./lib/build/tasks/browserify.js').task(env.browserify_watch, env.browserify_debug, ASSETS_DIR)
});
// Load Grunt tasks

@ -1,3 +1,4 @@
{
"browserify_debug": true,
"browserify_watch": true,

@ -1,3 +1,4 @@
{
"browserify_debug": false,
"browserify_watch": false,

@ -4,7 +4,11 @@ var entryBundles = require('../files/browserify_entry_bundles');
var concatBundles = require('../files/browserify_concat_bundles');
module.exports = {
task: function() {
task: function(browserifyWatch, browserifyDebug, assetsDir) {
if (browserifyWatch === undefined) throw new TypeError('browserifyWatch is required, expected a value of true|false');
if (browserifyDebug === undefined) throw new TypeError('browserifyDebug is required, expected a value of true|false');
if (typeof assetsDir !== 'string' || assetsDir.length === 0) throw new TypeError('assetsdir is required, expected a non-empty string');
var cfg = {
options: {
preBundleCB: function(b) {
@ -31,11 +35,12 @@ module.exports = {
transform: [],
// enables watchify when grunt is run with a watch task, e.g. `grunt browserify watch:js`
watch: '<%= env.browserify_watch %>',
watch: browserifyWatch,
browserifyOptions: {
browserifyOptions: {
// if true will include source maps
debug: '<%= env.browserify_debug %>' }
debug: browserifyDebug
}
};
if (bundle.options) {
@ -47,7 +52,7 @@ module.exports = {
cfg[name] = {
options: options,
src: bundle.src,
dest: bundle.dest || '<%= assets_dir %>/javascripts/' + name +'.js'
dest: bundle.dest || assetsDir +'/javascripts/' + name +'.js'
}
}
});

Loading…
Cancel
Save