-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
122 lines (102 loc) · 3.31 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
'use strict';
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var ts = require('gulp-typescript');
var babel = require('gulp-babel');
var del = require('del');
var tslint = require('gulp-tslint');
var connect = require('gulp-connect');
var uglify = require('gulp-uglify');
var karma = require('karma');
var open = require('open');
var rename = require('gulp-rename');
var tsProject = ts.createProject('tsconfig.json');
var tsSpecsProject = ts.createProject('tsconfig_specs.json');
// TODO: setup protractor
gulp.task('test', ['tscompile-specs'], function (done) {
gulp.start('test-raw');
return done();
});
gulp.task('test-raw', function (done) {
new karma.Server({
configFile: __dirname + '/karma.conf.coffee',
singleRun: true
}, done).start();
});
gulp.task('tslint', function () {
return gulp.src('src/**/*.ts')
.pipe(tslint())
.pipe(tslint.report('prose'));
});
gulp.task('clean-all', function (callback) {
return del('.tmp/*', callback);
return del('dist/*', callback);
});
gulp.task('copyhtml', ['clean-html'], function () {
return gulp.src('demo/**/*.html')
.pipe(gulp.dest('.tmp/'))
.pipe(connect.reload());
});
gulp.task('clean-html', function (callback) {
return del('.tmp/*.html', callback);
});
gulp.task('serve', ['copyhtml', 'tslint', 'tscompile', 'tscompile-specs'], function (callback) {
connect.server({
root: ['.tmp/', './bower_components'],
livereload: true,
host: 'renuo-upload.dev'
});
open('http://renuo-upload.dev:8080');
gulp.start('watch');
return callback();
});
gulp.task('tdd', ['copyhtml', 'tslint', 'tscompile', 'tscompile-specs'], function (done) {
gulp.start('watch');
return done();
});
gulp.task('ts-single-compile', ['clean-js-main'], function () {
return gulp.src('src/' + 'renuo_upload.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsProject))
.pipe(babel({presets: ['es2015']}))
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: 'src'}))
.pipe(gulp.dest('.tmp/'))
.pipe(connect.reload());
});
gulp.task('clean-js-main', function (callback) {
return del(['.tmp/renuo-upload.js', '.tmp/renuo-upload.js.map'], callback);
});
gulp.task('ts-specs-compile', ['clean-js-specs'], function () {
return gulp.src('src/**/*.spec.ts')
.pipe(sourcemaps.init())
.pipe(ts(tsSpecsProject))
.pipe(babel({presets: ['es2015']}))
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: 'src'}))
.pipe(gulp.dest('.tmp/'))
.pipe(connect.reload());
});
gulp.task('clean-js-specs', function (callback) {
return del(['.tmp/specs.js', '.tmp/specs.js.map'], callback);
});
gulp.task('watch', function (done) {
gulp.watch('src/**/*.ts', ['test', 'tscompile']);
gulp.watch('demo/**/*.html', ['copyhtml']);
return done();
});
gulp.task('clean-js-dist', function (callback) {
return del(['dist/renuo-upload.js', 'dist/renuo-upload.js.map'], callback);
});
gulp.task('dist', ['ts-single-compile'], function (done) {
return gulp.src('.tmp/renuo-upload.js')
.pipe(uglify({
wrap: true,
screwIE8: true
}))
.pipe(rename({
extname: '.min.js'
}))
.pipe(gulp.dest('dist'), done);
});
gulp.task('tscompile', ['tslint', 'ts-single-compile']);
gulp.task('tscompile-specs', ['tslint', 'ts-specs-compile']);
gulp.task('default', ['tslint', 'tscompile', 'test']);