diff options
| author | Dave Geddes | 2012-10-21 00:37:59 -0600 |
|---|---|---|
| committer | Igor Minar | 2013-03-05 23:35:13 -0800 |
| commit | 7a77fdae4f6a1a03734374aacc7264ebd6dbe94d (patch) | |
| tree | 603153ab33e9927adf72b3316a10c44f504430f9 /lib/grunt/plugins.js | |
| parent | b13da18e11d5f67696906d1ecd2fc9e753d50da4 (diff) | |
| download | angular.js-7a77fdae4f6a1a03734374aacc7264ebd6dbe94d.tar.bz2 | |
chore(Grunt): switch from Rake to Grunt
Migrates the Angular project from Rake to Grunt.
Benefits:
- Drops Ruby dependency
- Lowers barrier to entry for contributions from JavaScript ninjas
- Simplifies the Angular project setup and build process
- Adopts industry-standard tools specific to JavaScript projects
- Support building angular.js on Windows platform (really?!? why?!?)
BREAKING CHANGE: Rake is completely replaced by Grunt. Below are the deprecated Rake tasks and their Grunt equivalents:
rake --> grunt
rake package --> grunt package
rake init --> N/A
rake clean --> grunt clean
rake concat_scenario --> grunt build:scenario
rake concat --> grunt build
rake concat_scenario --> grunt build:scenario
rake minify --> grunt minify
rake version --> grunt write:version
rake docs --> grunt docs
rake webserver --> grunt webserver
rake test --> grunt test
rake test:unit --> grunt test:unit
rake test:<jqlite|jquery|modules|e2e> --> grunt test:<jqlite|jquery|modules|end2end|e2e>
rake test[Firefox+Safari] --> grunt test --browsers Firefox,Safari
rake test[Safari] --> grunt test --browsers Safari
rake autotest --> grunt autotest
NOTES:
* For convenience grunt test:e2e starts a webserver for you, while grunt test:end2end doesn't.
Use grunt test:end2end if you already have the webserver running.
* Removes duplicate entry for Describe.js in the angularScenario section of angularFiles.js
* Updates docs/src/gen-docs.js to use #done intead of the deprecated #end
* Uses grunt-contrib-connect instead of lib/nodeserver (removed)
* Removes nodeserver.sh, travis now uses grunt webserver
* Built and minified files are identical to Rake's output, with the exception of one less
character for git revisions (using --short) and a couple minor whitespace differences
Closes #199
Conflicts:
Rakefile
Diffstat (limited to 'lib/grunt/plugins.js')
| -rw-r--r-- | lib/grunt/plugins.js | 61 |
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()); + }); +}; |
