From a4d8186d074e5eff0fc97eb069389c1575a681df Mon Sep 17 00:00:00 2001 From: Simon Boudrias Date: Fri, 27 Dec 2013 01:49:58 -0500 Subject: [PATCH] First stab at gulp --- .travis.yml | 3 +-- gulpfile.js | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 14 ++++++++------ 3 files changed, 60 insertions(+), 8 deletions(-) create mode 100644 gulpfile.js diff --git a/.travis.yml b/.travis.yml index b2f182b5..028cf06d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,8 @@ language: node_js node_js: - '0.10' - '0.8' -script: "npm run-script travis" before_script: - - npm install -g bower mocha istanbul generator-angular + - npm install -g bower gulp - export NODE_PATH="$NVM_PATH/../node_modules" env: - DEBUG="generators:*" diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..13684f03 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,51 @@ +'use strict'; +var gulp = require('gulp'); +var mocha = require('gulp-mocha'); +var jshint = require('gulp-jshint'); +var jscs = require('gulp-jscs'); +var istanbul = require('gulp-istanbul'); +var coveralls = require('coveralls'); +var fs = require('fs'); +var path = require('path'); + +gulp.task('test', function (cb) { + var coverage = gulp.src(['lib/**/*.js', 'main.js']) + .pipe(istanbul()) + .on('end', function () { + gulp.src(['test/*.js']) + .pipe(mocha({ reporter: 'spec', timeout: 100000 })) + .pipe(istanbul.writeReports()) + .on('end', cb); + }); +}); + +gulp.task('default', function () { + gulp.src([ + 'test/*.js', + 'lib/**/*.js', + 'benchmark/**/*.js', + 'main.js', + 'doc.js', + 'gulpfile.js' + ]).pipe(jshint('.jshintrc')) + .pipe(jshint.reporter('jshint-stylish')) + .pipe(jscs()); + + gulp.run('test', function () { + var fileContents = fs.readFileSync(path.join(__dirname, 'coverage/lcov.info'), 'utf8'); + coveralls.getOptions(function (err, opt) { + if (err) throw err; + coveralls.convertLcovToCoveralls(fileContents, opt, function (err, data) { + if (err) throw err; + coveralls.sendToCoveralls(data, function (err, response, body) { + var status = JSON.parse(body); + if (!body.error) { + console.log('Coveralls: Success'); + } else { + console.log('Coveralls: Error ' + status.message); + } + }); + }); + }); + }); +}); diff --git a/package.json b/package.json index 08806729..873bbc8f 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,7 @@ "url": "git://github.com/yeoman/generator.git" }, "scripts": { - "test": "istanbul cover _mocha --report lcovonly -- test/*.js --reporter list --timeout 100000 && cat ./coverage/lcov.info", - "travis": "istanbul cover _mocha --report lcovonly -- test/*.js --reporter list --timeout 100000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", + "test": "gulp", "legacy": "mocha test/legacy.js --reporter dot --timeout 100000", "test-generator": "mocha test/generators/*.js --reporter spec --timeout 100000" }, @@ -51,13 +50,16 @@ "class-extend": "~0.1.0" }, "devDependencies": { - "mocha": "~1.15.1", "proxyquire": "~0.5.1", "sinon": "~1.7.3", "markdox": "~0.1.2", "coveralls": "~2.6.0", - "mocha-lcov-reporter": "0.0.1", - "istanbul": "~0.1.44", - "benchmark": "~1.0.0" + "benchmark": "~1.0.0", + "gulp": "~3.2.1", + "gulp-mocha": "~0.1.1", + "gulp-jshint": "~1.3.2", + "jshint-stylish": "~0.1.4", + "gulp-jscs": "~0.1.1", + "gulp-istanbul": "~0.1.0" } }