This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// This code gets run no matter what, | |
// so if this dep is slow to load, | |
// you will pay that tax every time you run `grunt`. | |
var bigDep = require('big-dependency'); | |
module.exports = function(grunt) { | |
grunt.registerTask('my-task', function myTaskFn() { | |
bigDep(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In the grunt config object | |
'set-async-config': { | |
'build-something': { | |
options: { | |
'key.into.grunt.config': function getAsyncValue() { | |
return getTmpDir('-tmp-dir-prefix'); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q.all(_.map(this.options(), function(configPromiseFn, configKey) { | |
var configPromise = configPromiseFn(); | |
return q(configPromise).then(function(configVal) { | |
grunt.verbose.ok('set-async-config: Setting key "' + configKey + '" to "' + configVal + '"'); | |
grunt.config(configKey, configVal); | |
}); | |
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask('unit', 'Run unit tests for your js.', [ | |
'set-async-config:angular-unit-make-tests', | |
'browserify:angular-module-tests', | |
'set-async-config:angular-unit', | |
'x-web-build-js:angular-module-lib', | |
'karma:once', | |
'set-async-config:angular-unit-min', | |
'x-web-build-js:angular-module-lib-min', | |
'karma:once', | |
]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask(‘task-a’, function() { | |
var uuid = require('uuid'), | |
result = doStuff(), | |
postTaskName = 'after-task-b-' + uuid.v4(); | |
grunt.registerTask(postTaskName, function() { | |
doMoreStuff(result); | |
}); | |
grunt.config(postTaskName, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask(‘task-a’, function() { | |
var result = doStuff(), | |
taskBFn = require('task-b'); | |
taskBFn({ | |
runtimeGenerated: arbitraryConfig(); | |
}).then(function() { | |
doMoreStuff(result); | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// How it is | |
grunt.registerTask('my-async-task', function() { | |
var done = this.async(); | |
doAsyncWork().then(done).fail(done); | |
}); | |
// How it should be | |
grunt.registerTask('my-async-task', function() { | |
return doAsyncWork(); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grunt.registerTask('my-task', function() { | |
var util = require('util'), | |
done = this.async(); | |
doAsyncWork().then(done).fail(function(err) { | |
done(util.isError(err) ? err : new Error(err)); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
function myTask(args) { | |
// do work | |
} | |
// tasks/task.js | |
module.exports = function(grunt) { | |
grunt.registerMultiTask('my-task', function() { | |
var myTask = require('../'); | |
var options = this.options(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// index.js | |
function myTask(rawArgs) { | |
var args = fillInDefaults(rawArgs, { | |
log: console.log | |
}); | |
} | |
// tasks/task.js | |
module.exports = function(grunt) { | |
grunt.registerMultiTask('my-task', function() { |