diff --git a/.travis.yml b/.travis.yml index 93286a05ae..0391af3b90 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ before_install: - npm install -g npm@'>=1.4.3' language: node_js node_js: - - "0.8" - "0.10" - "0.12" - "4" diff --git a/Makefile b/Makefile index 4acf1e524b..6e494e024f 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,8 @@ -REPORTER = dot - test: - @./node_modules/.bin/mocha \ - --reporter $(REPORTER) \ - --slow 200ms \ - --bail + @./node_modules/.bin/gulp test test-cov: - @./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \ - --reporter $(REPORTER) \ - test/ + @./node_modules/.bin/gulp test-cov .PHONY: test diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000000..c0788c8d7b --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,60 @@ +const gulp = require('gulp'); +const mocha = require('gulp-mocha'); +const babel = require("gulp-babel"); +const istanbul = require('gulp-istanbul'); +const help = require('gulp-task-listing'); +const del = require('del'); + +gulp.task('help', help); + +gulp.task('default', ['transpile']); + +const TRANSPILE_DEST_DIR = './dist'; + +// By default, individual js files are transformed by babel and exported to /dist +gulp.task('transpile', function () { + return gulp.src("lib/*.js") + .pipe(babel({ "presets": ["es2015"] })) + .pipe(gulp.dest(TRANSPILE_DEST_DIR)); +}); + +gulp.task('clean', function () { + return del([TRANSPILE_DEST_DIR]); +}) + +gulp.task('test', function(){ + return gulp.src('test/socket.io.js', {read: false}) + .pipe(mocha({ + slow: 200, + reporter: 'dot', + bail: true + })) + .once('error', function () { + process.exit(1); + }) + .once('end', function () { + process.exit(); + }); +}); + +gulp.task('istanbul-pre-test', function () { + return gulp.src(['lib/**/*.js']) + // Covering files + .pipe(istanbul()) + // Force `require` to return covered files + .pipe(istanbul.hookRequire()); +}); + +gulp.task('test-cov', ['istanbul-pre-test'], function(){ + return gulp.src('test/socket.io.js', {read: false}) + .pipe(mocha({ + reporter: 'dot' + })) + .pipe(istanbul.writeReports()) + .once('error', function (){ + process.exit(1); + }) + .once('end', function (){ + process.exit(); + }); +}); diff --git a/package.json b/package.json index 74a116318d..e4e276e498 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "url": "git://github.com/Automattic/socket.io" }, "scripts": { - "test": "mocha --reporter dot --slow 200ms --bail" + "test": "./node_modules/.bin/gulp test" }, "dependencies": { "engine.io": "1.6.8", @@ -29,7 +29,14 @@ "debug": "2.2.0" }, "devDependencies": { + "babel-preset-es2015": "6.3.13", + "del": "2.2.0", "expect.js": "0.3.1", + "gulp": "3.9.0", + "gulp-babel": "6.1.1", + "gulp-istanbul": "0.10.3", + "gulp-mocha": "2.2.0", + "gulp-task-listing": "1.0.1", "istanbul": "0.4.1", "mocha": "2.3.4", "superagent": "1.6.1",