-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
147 lines (115 loc) · 3.64 KB
/
gulpfile.js
File metadata and controls
147 lines (115 loc) · 3.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
var gulp = require('gulp');
var clean = require('gulp-clean');
var mocha = require('gulp-mocha');
var ts = require('gulp-typescript');
var tdoc = require("gulp-typedoc");
var webpack = require('webpack-stream');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var istanbul = require('gulp-istanbul');
//----------------------------
// PATHS
//----------------------------
var paths = {
javascripts: ['src/**/*.js', 'test/**/*.js'],
typescripts: ['src/**/*.ts', 'test/**/*.ts'],
testsources: ['src/**/*.js'],
typesources: ['src/**/*.ts'],
distsources: ['src/**/*.ts'],
clean: ['src/**/*.js', 'test/**/*.js', 'test/io/test_output/**/*.csv', 'build', 'dist', 'docs', 'build'],
tests_core: ['test/core/**/*.js'],
tests_adult: ['test/SaNGreeA/SaNGreeATests_adult.js'],
tests_house: ['test/SaNGreeA/SaNGreeATests_house.js']
};
//----------------------------
// TASKS
//----------------------------
gulp.task('build', function () { // ['clean'],
return gulp.src(paths.typescripts, {base: "."})
.pipe(ts({
target: "ES5",
module: "commonjs",
removeComments: true
}))
.pipe(gulp.dest('.'));
});
// Packaging - Node / Commonjs
gulp.task('dist', ['tdoc'], function () {
return gulp.src(paths.distsources)
.pipe(ts({
target: "ES5",
module: "commonjs",
removeComments: true
}))
.pipe(gulp.dest('dist'));
});
// Packaging - Webpack
gulp.task('pack', ['dist'], function() {
return gulp.src('./index.js')
.pipe(webpack( require('./webpack.config.js') ))
.pipe(gulp.dest('build/'));
});
// Uglification...
gulp.task('bundle', ['pack'], function() {
return gulp.src('build/anonymization.js')
.pipe(uglify())
.pipe(rename('anonymization.min.js'))
.pipe(gulp.dest('build'));
});
// Documentation (type doc)
gulp.task("tdoc", ['clean'], function() {
return gulp
.src(paths.typesources)
.pipe(tdoc({
module: "commonjs",
target: "es5",
out: "docs/",
name: "Graphinius"//,
// theme: "minimal"
}));
});
gulp.task('test-core', ['build'], function () {
return gulp.src(paths.tests_core, {read: false})
.pipe(mocha({reporter: 'spec',
timeout: Number.POSITIVE_INFINITY}));
});
gulp.task('test-adult', ['build'], function () {
return gulp.src(paths.tests_adult, {read: false})
.pipe(mocha({reporter: 'spec',
timeout: Number.POSITIVE_INFINITY}));
});
gulp.task('test-house', ['build'], function () {
return gulp.src(paths.tests_house, {read: false})
.pipe(mocha({reporter: 'spec',
timeout: Number.POSITIVE_INFINITY}));
});
gulp.task('pre-cov-test', ['build'], function () {
return gulp.src(paths.testsources)
// Covering files
.pipe(istanbul())
// Force `require` to return covered files
.pipe(istanbul.hookRequire());
});
gulp.task('coverage', ['pre-cov-test'], function () {
return gulp.src(paths.tests)
.pipe(mocha({reporter: 'dot',
timeout: Number.POSITIVE_INFINITY}))
// Creating the reports after tests ran
.pipe(istanbul.writeReports())
// Enforce a coverage of at least 90%
// .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }));
});
gulp.task('clean', function () {
return gulp.src(paths.clean, {read: false})
.pipe(clean());
});
gulp.task('watch-core', function () {
gulp.watch(paths.typescripts, ['test-core']);
});
gulp.task('watch-adult', function () {
gulp.watch(paths.typescripts, ['test-adult']);
});
gulp.task('watch-house', function () {
gulp.watch(paths.typescripts, ['test-house']);
});
gulp.task('default', ['watch']);