-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
110 lines (97 loc) · 2.4 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
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
var gulp = require('gulp');
var ts = require('gulp-typescript');
var runSequence = require('run-sequence');
var typescript = require('typescript');
var sourcemaps = require('gulp-sourcemaps');
var rimraf = require('gulp-rimraf');
var sass = require('gulp-sass');
var jasmine = require('gulp-jasmine');
const reporters = require('jasmine-reporters');
var watch = require('gulp-watch');
var nodeServer = require('gulp-develop-server');
var Karma = require('karma').Server;
var browserSync = require('browser-sync').create();
var typings = require("gulp-typings");
var watching = false;
// Main task
gulp.task('default' , function () {
runSequence(
['typescript-server', 'ace-mips-mode']
);
});
gulp.task('watch', function() {
watching = true;
runSequence(
[
'typescript-server-watch',
],
['jasmine-server']
)
});
gulp.task('test_server', function() {
runSequence(
['typescript-server'],
'jasmine-server',
function (err) {
if (err) {
failOnSingleBuild();
}
}
)
});
function failOnSingleBuild() {
if (!watching)
process.exit(1);
}
var tsServerProject = ts.createProject('tsconfig.server.json', {
typescript: typescript
});
gulp.task('typescript-server', function() {
return gulp.src(['src/server/**/**.ts', 'src/common/**/**.ts'], {base: 'src/'})
.pipe(sourcemaps.init())
.pipe(ts(tsServerProject))
.on('error', failOnSingleBuild)
.pipe(sourcemaps.write())
.pipe(gulp.dest('dist'));
});
gulp.task('typescript-server-watch', function() {
return gulp.watch(
['src/server/**/**.ts', 'src/common/**/**.ts'],
['typescript-server', nodeServer.restart]
);
});
gulp.task('ace-mips-mode', function() {
return gulp.src('src/client/ace/mode-mips.js')
.pipe(gulp.dest('dist/public/'))
});
gulp.task('clean', function() {
return gulp.src(['dist/'])
.pipe(rimraf())
});
gulp.task('jasmine-server', function() {
gulp.src(["dist/server/**/*.spec.js"])
.pipe(jasmine({
reporter: new reporters.JUnitXmlReporter({
savePath: '/tests/server/',
consolidateAll: true
}),
errorOnFail: true
}))
.on('error', failOnSingleBuild)
});
gulp.task('karma', function(done) {
new Karma({
configFile: __dirname + '/karma.conf.js'
}, done).start()
});
gulp.task('karma-watch', function(done) {
new Karma({
configFile: __dirname + '/karma.conf.js',
singleRun: false
}, done).start()
});
gulp.task('api-tests', function (done) {
new Karma({
singleRun: true,
}, done).start();
})