diff --git a/.gitignore b/.gitignore index c43b3a21..f53fcf5e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,10 +2,8 @@ .tern-port coverage/ node_modules/.bin -node_modules/grunt* +node_modules/gulp* node_modules/istanbul -node_modules/jshint -node_modules/load-grunt-tasks # User-specific files conf.json diff --git a/.npmignore b/.npmignore index 04a56b32..aaa8ad0a 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,9 @@ # development-related files -.jshintrc +.eslintignore +.eslintrc +.gitignore .travis.yml -Gruntfile.js +gulpfile.js # scripts for launching JSDoc with Mozilla Rhino /jsdoc* diff --git a/.travis.yml b/.travis.yml index 4806b2c2..32230bda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,6 @@ language: node_js node_js: - "0.10" + - "0.11" -install: npm install -g grunt-cli; npm install +install: npm install -g gulp; npm install diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index 07b90e87..00000000 --- a/Gruntfile.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict'; - -var os = require('os'); -var path = require('path'); - -module.exports = function(grunt) { - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - nodeBin: path.resolve(__dirname, './jsdoc.js'), - nodePath: process.execPath, - rhinoBin: (function() { - var filepath = path.resolve(__dirname, './jsdoc'); - - if (os.platform().indexOf('win') === 0) { - filepath += '.cmd'; - } - - return filepath; - })(), - - bumpup: { - options: { - updateProps: { - pkg: 'package.json' - } - }, - setters: { - date: function(oldDate, releaseType, options) { - return oldDate; - }, - version: function(oldVersion, releaseType, options) { - return oldVersion; - }, - revision: function(oldVersion, releaseType, options) { - return String( Date.now() ); - } - }, - files: ['package.json'] - }, - eslint: { - target: [ - '*.js', - 'lib/**/*.js', - 'plugins/*.js', - 'templates/default/*.js', - 'templates/haruki/*.js' - ] - }, - shell: { - 'coverage': { - command: './node_modules/.bin/istanbul cover <%= nodeBin %> -- -T', - options: { - stdout: true, - stderr: true - } - }, - 'test-rhino': { - command: '<%= rhinoBin %> -T -q "parser=rhino"', - options: { - failOnError: true, - stdout: true, - stderr: true - } - }, - 'test-rhino-esprima': { - command: '<%= rhinoBin %> -T -q "parser=esprima"', - options: { - failOnError: true, - stdout: true, - stderr: true - } - }, - 'test-node': { - command: '<%= nodePath %> <%= nodeBin %> -T', - options: { - failOnError: true, - stdout: true, - stderr: true - } - } - } - }); - - require('load-grunt-tasks')(grunt); - - grunt.renameTask('bumpup', 'bump'); - - grunt.registerTask('coverage', ['shell:coverage']); - - grunt.registerTask('test-rhino', ['shell:test-rhino']); - grunt.registerTask('test-rhino-esprima', ['shell:test-rhino-esprima']); - grunt.registerTask('test-node', ['shell:test-node']); - grunt.registerTask('test', ['test-rhino', 'test-rhino-esprima', 'test-node', 'eslint']); - - grunt.registerTask('default', ['test']); -}; diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..f333ea5c --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,82 @@ +/*eslint max-nested-callbacks: 0 */ +'use strict'; + +var bump = require('gulp-bump'); +var eslint = require('gulp-eslint'); +var exec = require('child_process').exec; +var gulp = require('gulp'); +var istanbul = require('istanbul'); +var os = require('os'); +var path = require('path'); +var util = require('util'); + +function execCb(cb, err, stdout, stderr) { + console.log(stdout); + console.error(stderr); + cb(err); +} + +var options = { + coveragePaths: [ + '*.js', + 'lib/**/*.js', + 'plugins/*.js' + ], + lintPaths: [ + '*.js', + 'lib/**/*.js', + 'plugins/*.js', + 'templates/default/*.js', + 'templates/haruki/*.js' + ], + nodeBin: path.resolve(__dirname, './jsdoc.js'), + nodePath: process.execPath, + rhinoBin: (function() { + var filepath = path.resolve(__dirname, './jsdoc'); + + if (os.platform().indexOf('win') === 0) { + filepath += '.cmd'; + } + + return filepath; + })() +}; + +gulp.task('bump', function() { + gulp.src('./package.json') + .pipe(bump({ + key: 'revision', + version: String( Date.now() ) + })) + .pipe(gulp.dest('./')); +}); + +gulp.task('coverage', function(cb) { + var cmd = util.format('./node_modules/.bin/istanbul cover %s -- -T', options.nodeBin); + exec(cmd, execCb.bind(null, cb)); +}); + +gulp.task('lint', function() { + var pipeline = gulp.src(options.lintPaths) + .pipe(eslint()) + .pipe(eslint.formatEach()) + .pipe(eslint.failOnError()); +}); + +gulp.task('test-node', function(cb) { + var cmd = util.format('%s %s -T', options.nodePath, options.nodeBin); + exec(cmd, execCb.bind(null, cb)); +}); + +gulp.task('test-rhino', function(cb) { + var cmd = util.format('%s -T -q "parser=rhino"', options.rhinoBin); + exec(cmd, execCb.bind(null, cb)); +}); + +gulp.task('test-rhino-esprima', function(cb) { + var cmd = util.format('%s -T -q "parser=esprima"', options.rhinoBin); + exec(cmd, execCb.bind(null, cb)); +}); + +gulp.task('test', ['lint', 'test-node', 'test-rhino', 'test-rhino-esprima']); +gulp.task('default', ['test']); diff --git a/package.json b/package.json index 9f0c826a..66cab020 100644 --- a/package.json +++ b/package.json @@ -28,12 +28,10 @@ "wrench": "~1.3.9" }, "devDependencies": { - "grunt": "~0.4.2", - "grunt-bumpup": "~0.4.2", - "grunt-eslint": "~0.4.0", - "grunt-shell": "~0.6.1", + "gulp": "~3.6.2", + "gulp-bump": "~0.1.8", + "gulp-eslint": "~0.1.6", "istanbul": "~0.2.1", - "load-grunt-tasks": "~0.2.1", "tv4": "https://github.com/hegemonic/tv4/tarball/own-properties" }, "engines": { @@ -41,7 +39,7 @@ }, "scripts": { "postinstall": "node ./node/postinstall.js", - "test": "grunt test" + "test": "gulp test" }, "bin": { "jsdoc": "./jsdoc.js"