-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2471 from nus-fboa2016-si/gulp-rebased
Add gulp and babel
- Loading branch information
Showing
4 changed files
with
70 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters