-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
94 lines (81 loc) · 2.64 KB
/
gulpfile.js
File metadata and controls
94 lines (81 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
var gulp = require('gulp')
var gutil = require('gulp-util')
var jscs = require('gulp-jscs')
var jshint = require('jshint')
var gulpJshint = require('gulp-jshint')
var jshintStylish = require('jshint-stylish')
var mocha = require('gulp-mocha')
var babel = require('gulp-babel')
var sourcemaps = require('gulp-sourcemaps')
require('babel/register')
var mochaReporter = require('./test/support/gulp-mocha-reporter')
var ipfsMock = require('./test/support/mock-ipfs')
var globs = {
javascripts: ['{lib,test,bin,demos,script}/**/*.js', '*.js'],
dist_javascripts: ['lib/**/*.js'],
package_json: ['package.json'],
rc_files: ['./.js*rc'],
unit_tests: ['test/unit/**/*.js'],
integration_tests: ['test/integration/**/*.js'],
test_support: ['test/support/**/*.js'],
}
gulp.task('build', function () {
return gulp.src(globs.dist_javascripts)
.pipe(sourcemaps.init())
.pipe(babel({
optional: ['runtime', 'strict'],
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist'))
})
gulp.task('watch-build', ['build'], function () {
return gulp.watch(globs.javascripts, ['build'])
})
gulp.task('jscs', function () {
return gulp.src(globs.javascripts)
.pipe(jscs())
})
gulp.task('jshint', function () {
return gulp.src([].concat(globs.javascripts, globs.package_json, globs.rc_files))
.pipe(gulpJshint({ linter: jshint.JSHINT }))
.pipe(gulpJshint.reporter(jshintStylish))
})
gulp.task('lint', ['jscs', 'jshint'])
gulp.task('watch-lint', function () {
return gulp.watch(globs.javascripts, ['lint'])
})
gulp.task('unit-tests', function () {
return gulp.src(globs.unit_tests, { read: false })
.pipe(mocha({ reporter: mochaReporter, }))
.once('end', function () {
return ipfsMock.stop()
})
})
gulp.task('integration-tests', function () {
return gulp.src(globs.integration_tests, { read: false })
.pipe(mocha({ reporter: mochaReporter, }))
.once('end', function () {
return ipfsMock.stop()
})
})
gulp.task('test', ['unit-tests', 'lint'])
gulp.task('watch-unit-tests', function () {
gulp.watch([].concat(globs.dist_javascripts, globs.unit_tests, globs.test_support), ['unit-tests'])
})
gulp.task('watch-integration-tests', function () {
gulp.watch([].concat(globs.dist_javascripts, globs.integration_tests, globs.test_support), ['integration-tests'])
})
gulp.task('default', [
'watch-build',
'watch-lint',
'watch-unit-tests',
'test',
'watch-gulpfile',
])
gulp.task('watch-gulpfile', function () {
// run a gulp loop like this: `(set -e; while true; do clear; gulp; done)`
return gulp.watch(__filename, function () {
gutil.log(__filename + ' has changed; exiting.')
process.exit()
})
})