-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
147 lines (127 loc) · 3.57 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
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 path = require('path');
var ts = require('gulp-typescript');
var del = require('del');
var runSequence = require('run-sequence');
var gls = require('gulp-live-server');
var mocha = require('gulp-mocha');
//var Service = require('node-windows').Service;
var config = {
"buildDir": "dist/",
"tsOptions": {
"target": "ES6",
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typescript": require('typescript'),
"sortOutput": true
},
"files": [
"node_modules/reflect-metadata/reflect-metadata.d.ts",
"node_modules/inversify-dts/inversify/inversify.d.ts",
"typings/index.d.ts",
"src/**/*.ts"
],
"watchFiles": [
"src/**/*.ts"
]
};
/* Create a new service object
var svc = new Service({
name:'SyncPipes Server',
description: 'SyncPipes server as a windows service.',
script: 'app.js'
});
*/
gulp.task('default', ['build']);
/**
* Build application
*/
gulp.task('build', function (callback) {
runSequence('clean', 'copy', 'compile', callback);
});
/**
* Compile typescript
*/
gulp.task('compile', function () {
return gulp
.src(config.files)
.pipe(ts(config.tsOptions))
.pipe(gulp.dest(config.buildDir));
});
/**
* Copy non typescript files
*/
gulp.task('copy', function () {
return gulp.src(["!src/services/**/*.ts", "src/services/**/*"], {base: './src'}).pipe(gulp.dest(config.buildDir));
});
/**
* Delete build files
*/
gulp.task('clean', function () {
return del(config.buildDir);
});
/**
* Watch files and build
*/
gulp.task('watch', [ 'build' ], function () {
gulp.watch(config.watchFiles, [ 'build' ]);
});
/**
* Run server and worker
*/
gulp.task('serve', ['build'], function () {
var server = gls('dist/server.js', undefined, false);
var worker = gls('dist/worker.js', undefined, false);
server.start();
worker.start();
gulp.watch(config.watchFiles, function () {
runSequence('compile', function() {
server.start.bind(server)();
worker.start.bind(worker)();
});
});
});
/*
gulp.task('install:service', ['build'], function () {
// Listen for the "install" event, which indicates the
// process is available as a service.
svc.on('install',function(){
svc.start();
});
svc.on('alreadyinstalled',function(){
console.log('This service is already installed.');
});
svc.on('start',function(){
console.log(svc.name+' started!\nVisit http://127.0.0.1:3010 to see it in action.');
});
svc.install();
});
gulp.task('uninstall:service', ['build'], function () {
// Listen for the "uninstall" event so we know when it's done.
svc.on('uninstall',function(){
console.log('Uninstall complete.');
console.log('The service exists: ',svc.exists);
});
// Uninstall the service.
svc.uninstall();
});
*/
/**
* Invoke tests
*/
gulp.task('test', ['build'], function () {
return gulp.src('dist/**/*.{test,spec}.js', {read: false}).pipe(mocha());
});
gulp.task('test:services', ['build'], function () {
return gulp.src('dist/services/**/*.{test,spec}.js', {read: false}).pipe(mocha());
});
gulp.task('test:app', ['build'], function () {
return gulp.src('dist/app/**/*.{test,spec}.js', {read: false}).pipe(mocha());
});
gulp.task('test:scservice', ['build'], function () {
return gulp.src('dist/services/scExtractor/**/*.{test,spec}.js', {read: false}).pipe(mocha());
});