Skip to content

Commit

Permalink
Merge pull request #2471 from nus-fboa2016-si/gulp-rebased
Browse files Browse the repository at this point in the history
Add gulp and babel
  • Loading branch information
rauchg committed Mar 13, 2016
2 parents b3fc530 + 355b515 commit c7de1a1
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 2 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down

0 comments on commit c7de1a1

Please sign in to comment.