-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
72 lines (62 loc) · 1.81 KB
/
gulpfile.js
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
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
// var mocha = require('gulp-mocha');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
var rename = require('gulp-rename');
var exorcist = require('exorcist');
var watch = require('gulp-watch');
var tsify = require('tsify');
var watchify = require('watchify');
var walkSync = require('walk-sync');
var path = require('path');
var mocha = require('gulp-mocha');
var main = './src/neutrino.ts';
var typingsCache = {};
var opts = {
entries: [main],
debug: true,
cache: {},
packageCache: {}
};
var b = browserify(opts)
.plugin(tsify, {
target: 'es6',
module: 'system',
sourcemap: true
})
.plugin(watchify)
.transform(babelify, {
presets: ['es2015', 'stage-0'],
extensions: ['.ts']
});
b.on('update', build);
function build(done) {
console.log('Adding typings.....');
walkSync('typings').forEach(function(file) {
if (file.match(/\.d\.ts$/) && !typingsCache.hasOwnProperty(file)) {
console.log('Adding typing: ' + file);
b.add('typings/' + file);
typingsCache[file] = true;
}
});
console.log('Building Neutrino....');
b.bundle()
.on('error', console.log)
.on('end', () => {
console.log('Done!');
})
.on('missing-map', () => {
console.log('Missing map!');
})
.pipe(exorcist(path.join(__dirname, 'dist', 'neutrino.js.map'), null, path.join(__dirname, 'src')))
.pipe(source(main))
.pipe(rename('./neutrino.js'))
.pipe(gulp.dest('./dist'));
}
gulp.task('build', build);
gulp.task('test', () => {
return gulp.src('./test/test.js', {read: false})
.pipe(mocha({reporter: 'nyan'}));
});