forked from Makeblock-official/neuron-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
77 lines (63 loc) · 2.16 KB
/
Gulpfile.js
File metadata and controls
77 lines (63 loc) · 2.16 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
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var uglify = require('gulp-uglify');
gulp.task('jshint', function() {
gulp.src(['**/*.js', '!node_modules/**', '!test/**', '!benchmark/**','!browser/**','!coverage/**','!neurons-engine/**','!*.js'])
.pipe(jshint({
node: true
}))
.pipe(jshint.reporter());
});
gulp.task('pre-test', function() {
// This tells gulp which files you want to pipe
// In our case we want to pipe every `.js` file inside any folders inside `test`
return gulp.src('lib/**/*.js')
.pipe(istanbul())
// This overwrites `require` so it returns covered files
.pipe(istanbul.hookRequire());
});
gulp.task('test', ['pre-test'], function() {
// Here we're piping our `.js` files inside the `lib` folder
gulp.src('test/unit/**/*.js')
// You can change the reporter if you want, try using `nyan`
.pipe(mocha({reporter: 'spec'}))
// Here we will create report files using the test's results
.pipe(istanbul.writeReports())
.once('end', function () {
process.exit();
});;
});
gulp.task('browserify', function() {
browserify('./lib/engine/logic/index.js')
.ignore('./lib/driver/serial.js')
.bundle()
.pipe(source('neurons_logic_engine.js'))
.pipe(gulp.dest('./browser/'));
browserify('./lib/engine/flow/index.js')
.ignore('./lib/driver/serial.js')
.bundle()
.pipe(source('neurons_flow_engine.js'))
.pipe(gulp.dest('./browser/'));
browserify('./index.js')
.ignore('./lib/driver/serial.js')
.bundle()
.pipe(source('./neurons_engine.js'))
.pipe(gulp.dest('./browser/'));
});
gulp.task('compress', function() {
gulp.src('./browser/neurons_logic_engine.js')
.pipe(uglify())
.pipe(gulp.dest('./browser/'));
gulp.src('./browser/neurons_flow_engine.js')
.pipe(uglify())
.pipe(gulp.dest('./browser/'));
gulp.src('./browser/neurons_engine.js')
.pipe(uglify())
.pipe(gulp.dest('./browser/'));
});
gulp.task('default', ['test'], function() {
});