Skip to content

Commit c7de1a1

Browse files
committed
Merge pull request #2471 from nus-fboa2016-si/gulp-rebased
Add gulp and babel
2 parents b3fc530 + 355b515 commit c7de1a1

File tree

4 files changed

+70
-11
lines changed

4 files changed

+70
-11
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ before_install:
33
- npm install -g npm@'>=1.4.3'
44
language: node_js
55
node_js:
6-
- "0.8"
76
- "0.10"
87
- "0.12"
98
- "4"

Makefile

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11

2-
REPORTER = dot
3-
42
test:
5-
@./node_modules/.bin/mocha \
6-
--reporter $(REPORTER) \
7-
--slow 200ms \
8-
--bail
3+
@./node_modules/.bin/gulp test
94

105
test-cov:
11-
@./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- \
12-
--reporter $(REPORTER) \
13-
test/
6+
@./node_modules/.bin/gulp test-cov
147

158
.PHONY: test

gulpfile.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const gulp = require('gulp');
2+
const mocha = require('gulp-mocha');
3+
const babel = require("gulp-babel");
4+
const istanbul = require('gulp-istanbul');
5+
const help = require('gulp-task-listing');
6+
const del = require('del');
7+
8+
gulp.task('help', help);
9+
10+
gulp.task('default', ['transpile']);
11+
12+
const TRANSPILE_DEST_DIR = './dist';
13+
14+
// By default, individual js files are transformed by babel and exported to /dist
15+
gulp.task('transpile', function () {
16+
return gulp.src("lib/*.js")
17+
.pipe(babel({ "presets": ["es2015"] }))
18+
.pipe(gulp.dest(TRANSPILE_DEST_DIR));
19+
});
20+
21+
gulp.task('clean', function () {
22+
return del([TRANSPILE_DEST_DIR]);
23+
})
24+
25+
gulp.task('test', function(){
26+
return gulp.src('test/socket.io.js', {read: false})
27+
.pipe(mocha({
28+
slow: 200,
29+
reporter: 'dot',
30+
bail: true
31+
}))
32+
.once('error', function () {
33+
process.exit(1);
34+
})
35+
.once('end', function () {
36+
process.exit();
37+
});
38+
});
39+
40+
gulp.task('istanbul-pre-test', function () {
41+
return gulp.src(['lib/**/*.js'])
42+
// Covering files
43+
.pipe(istanbul())
44+
// Force `require` to return covered files
45+
.pipe(istanbul.hookRequire());
46+
});
47+
48+
gulp.task('test-cov', ['istanbul-pre-test'], function(){
49+
return gulp.src('test/socket.io.js', {read: false})
50+
.pipe(mocha({
51+
reporter: 'dot'
52+
}))
53+
.pipe(istanbul.writeReports())
54+
.once('error', function (){
55+
process.exit(1);
56+
})
57+
.once('end', function (){
58+
process.exit();
59+
});
60+
});

package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"url": "git://github.com/Automattic/socket.io"
1919
},
2020
"scripts": {
21-
"test": "mocha --reporter dot --slow 200ms --bail"
21+
"test": "./node_modules/.bin/gulp test"
2222
},
2323
"dependencies": {
2424
"engine.io": "1.6.8",
@@ -29,7 +29,14 @@
2929
"debug": "2.2.0"
3030
},
3131
"devDependencies": {
32+
"babel-preset-es2015": "6.3.13",
33+
"del": "2.2.0",
3234
"expect.js": "0.3.1",
35+
"gulp": "3.9.0",
36+
"gulp-babel": "6.1.1",
37+
"gulp-istanbul": "0.10.3",
38+
"gulp-mocha": "2.2.0",
39+
"gulp-task-listing": "1.0.1",
3340
"istanbul": "0.4.1",
3441
"mocha": "2.3.4",
3542
"superagent": "1.6.1",

0 commit comments

Comments
 (0)