This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
46 lines (38 loc) · 1.53 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
const gulp = require('gulp');
const del = require('del');
const merge = require('merge2');
const path = require('path');
const shell = require('gulp-shell');
const sourcemaps = require('gulp-sourcemaps');
const tslint = require('gulp-tslint');
const tsc = require('gulp-typescript');
const tsp = tsc.createProject('tsconfig.json');
gulp.task('clean-generated', function _cleanTypescript() {
const distFiles = ['./dist/**/*.*'];
return del(distFiles);
});
gulp.task('lint-ts', function _lintTypescript() {
return tsp.src().pipe(tslint({ formatter: 'verbose' })).pipe(tslint.report());
});
gulp.task('compile-ts', ['clean-generated', 'lint-ts'], function _compileTypescript() {
const result = tsp.src().pipe(sourcemaps.init()).pipe(tsp());
return merge([
result.dts.pipe(gulp.dest('dist')),
result.js.pipe(sourcemaps.write('.',
{
includeContent: false,
sourceRoot: function _sourceRoot(file) {
const srcFile = path.join(file.cwd, file.sourceMap.file);
return '../' + path.relative(path.dirname(srcFile), __dirname);
}
}
)).pipe(gulp.dest('dist'))
]);
});
gulp.task('npm-files', function _npmFileGathering() {
return gulp.src(['README.md', 'LICENSE', 'package.json']).pipe(gulp.dest('dist'));
});
gulp.task('publish', ['default'], shell.task([
'cd dist && pwd && npm publish --access public && npm pack'
]));
gulp.task('default', ['clean-generated', 'lint-ts', 'compile-ts', 'npm-files']);