forked from thibauts/b-spline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 lines (49 loc) · 1.74 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
'use strict';
const gulp = require('gulp'),
tsc = require('gulp-typescript'),
tslint = require('gulp-tslint'),
sourcemaps = require('gulp-sourcemaps'),
Config = require('./gulpfile.config'),
tsProject = tsc.createProject('tsconfig.json', {typescript:require("typescript")});
const rimrafSync = require('rimraf').sync;
const config = new Config();
/**
* Lint all custom TypeScript files.
*/
gulp.task('ts-lint', function () {
return gulp.src(config.allTypeScript)
.pipe(tslint({
formatter: "verbose"
}))
.pipe(tslint.report());
});
/**
* Compile TypeScript and include references to library and app .d.ts files.
*/
gulp.task('compile-ts', function () {
var sourceTsFiles = [ config.allTypeScript, //path to typescript files
config.libraryTypeScriptDefinitions ]; //reference to library .d.ts files
var tsResult = gulp.src(sourceTsFiles)
.pipe(sourcemaps.init())
.pipe(tsc(tsProject));
tsResult.dts.pipe(gulp.dest(config.tsOutputPath));
return tsResult.js
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(config.tsOutputPath));
});
/**
* Remove all generated JavaScript files from TypeScript compilation.
*/
gulp.task('clean-ts', function (cb) {
var typeScriptGenFiles = [
config.tsOutputPath + '/**/*.js', // path to all JS files auto gen'd by editor
config.tsOutputPath + '/**/*.js.map', // path to all sourcemap files auto gen'd by editor
'!' + config.tsOutputPath + '/lib'
];
// delete the files
rimrafSync(typeScriptGenFiles, cb);
});
gulp.task('watch', function () {
gulp.watch([ config.allTypeScript ], [ 'ts-lint', 'compile-ts' ]);
});
gulp.task('default', [ 'ts-lint', 'compile-ts' ]);