-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
84 lines (73 loc) · 1.94 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
/*
* Copyright (c) 2015-2019, Michael A. Updike All rights reserved.
* Licensed under the BSD-3-Clause
* https://opensource.org/licenses/BSD-3-Clause
* https://github.com/opus1269/screensaver/blob/master/LICENSE.md
*/
'use strict';
// paths and files
const base = {
app: './',
src: 'src/',
docs: 'docs/',
dest: './',
};
const files = {
ts: `${base.src}**/*.ts`,
js: [`${base.app}gulpfile.js`],
};
// plugins
const gulp = require('gulp');
const plumber = require('gulp-plumber');
const eslint = require('gulp-eslint');
const ts = require('gulp-typescript');
const tsProject = ts.createProject('tsconfig.json');
const tslint = require('gulp-tslint');
const typedoc = require('gulp-typedoc');
// Lint development js files
function jsLint() {
const input = files.js;
return gulp.src(input, {base: '.'}).
pipe(eslint()).
pipe(eslint.formatEach()).
pipe(eslint.failOnError());
}
// Lint TypeScript files
function tsLint() {
const input = files.ts;
return gulp.src(input, {base: '.'}).
pipe(tslint({
formatter: 'verbose',
})).
pipe(plumber()).
pipe(tslint.report({emitError: false}));
}
// Compile the typescript to js in place
function tsCompile() {
console.log('compiling ts to js...');
const input = files.ts;
return gulp.src(input, {base: '.'}).
pipe(tsProject(ts.reporter.longReporter())).js.
pipe(gulp.dest(base.dest));
}
// watch for file changes
function watch() {
gulp.watch(files.ts, gulp.series(tsLint));
gulp.watch(files.js, gulp.series(jsLint));
}
// Generate Typedoc
function docs() {
const input = files.ts;
return gulp.src(input).pipe(typedoc({
mode: 'modules',
module: 'system',
target: 'ES6',
out: 'docs/gen',
name: 'Common Custom Elements',
readme: 'README.md',
tsconfig: 'tsconfig.json'}));
}
exports.develop = watch;
exports.build = gulp.series(jsLint, tsLint, tsCompile, docs);
exports.docs = docs;
exports.default = watch;