-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
57 lines (49 loc) · 1.46 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
const del = require('del');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const ts = require('gulp-typescript');
//
// Define path constants.
//
const paths = {
build: {
output: 'built'
},
package: 'package',
source: 'src',
test: 'test',
typescript: {
config: 'tsconfig.json'
}
};
//
// Define task building block functions.
//
var tsProject = ts.createProject(paths.typescript.config);
function buildSource() {
return tsProject.src()
.pipe(tsProject())
.js.pipe(gulp.dest(paths.build.output));
}
function clean() {
return del([`${paths.build.output}/**/*`, `${paths.package}/**/*`]);
}
function runTests() {
return gulp.src(`${paths.test}/**/*.spec.ts`)
.pipe(mocha({
reporter: 'nyan',
require: ['ts-node/register']
}));
}
function stagePackage() {
gulp.src(['LICENSE', 'package.json', 'README.md'], { base: './' }).pipe(gulp.dest(`${paths.package}/`));
gulp.src([`${paths.source}/**/*.d.ts`], { base: `${paths.source}/` }).pipe(gulp.dest(`${paths.package}/lib/`));
return gulp.src([`${paths.build.output}/${paths.source}/**/*.js`], { base: `${paths.build.output}/${paths.source}/` })
.pipe(gulp.dest(`${paths.package}/lib/`));
}
//
// Define gulp tasks.
//
gulp.task('default', gulp.series(clean, buildSource, gulp.parallel(runTests, stagePackage)));
gulp.task('build', gulp.series(clean, buildSource));
gulp.task('test', runTests);