aboutsummaryrefslogtreecommitdiffstats
path: root/lib/grunt/plugins.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/grunt/plugins.js')
-rw-r--r--lib/grunt/plugins.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/grunt/plugins.js b/lib/grunt/plugins.js
new file mode 100644
index 00000000..c67aa545
--- /dev/null
+++ b/lib/grunt/plugins.js
@@ -0,0 +1,61 @@
+var util = require('./utils.js');
+var spawn = require('child_process').spawn;
+
+module.exports = function(grunt) {
+
+ grunt.registerMultiTask('min', 'minify JS files', function(){
+ util.min.call(util, this.data, this.async());
+ });
+
+
+ grunt.registerTask('minall', 'minify all the JS files in parallel', function(){
+ var files = grunt.config('min');
+ files = Object.keys(files).map(function(key){ return files[key]; });
+ grunt.util.async.forEach(files, util.min.bind(util), this.async());
+ });
+
+
+ grunt.registerMultiTask('build', 'build JS files', function(){
+ util.build.call(util, this.data, this.async());
+ });
+
+
+ grunt.registerTask('buildall', 'build all the JS files in parallel', function(){
+ var builds = grunt.config('build');
+ builds = Object.keys(builds).map(function(key){ return builds[key]; });
+ grunt.util.async.forEach(builds, util.build.bind(util), this.async());
+ });
+
+
+ grunt.registerMultiTask('write', 'write content to a file', function(){
+ grunt.file.write(this.data.file, this.data.val);
+ grunt.log.ok('wrote to ' + this.data.file);
+ });
+
+
+ grunt.registerMultiTask('docs', 'create angular docs', function(){
+ var done = this.async();
+ var files = this.data;
+ var docs = spawn('node', ['docs/src/gen-docs.js']);
+ docs.stdout.pipe(process.stdout);
+ docs.stderr.pipe(process.stderr);
+ docs.on('exit', function(code){
+ if(code !== 0) grunt.fail.warn('Error creating docs');
+ grunt.file.expand(files).forEach(function(file){
+ grunt.file.write(file, util.process(grunt.file.read(file), grunt.config('NG_VERSION'), false));
+ });
+ grunt.log.ok('docs created');
+ done();
+ });
+ });
+
+
+ grunt.registerMultiTask('test', 'Run the unit tests with testacular', function(){
+ util.startTestacular.call(util, this.data, true, this.async());
+ });
+
+
+ grunt.registerMultiTask('autotest', 'Run and watch the unit tests with testacular', function(){
+ util.startTestacular.call(util, this.data, false, this.async());
+ });
+};