vscode-vsce/gulpfile.js

57 lines
1.4 KiB
JavaScript
Raw Normal View History

2016-07-21 09:40:54 +02:00
'use strict';
const gulp = require('gulp');
2017-03-14 14:12:55 +01:00
const gts = require('gulp-typescript');
2017-03-14 09:52:51 +01:00
const sm = require('gulp-sourcemaps');
2016-07-21 09:40:54 +02:00
const filter = require('gulp-filter');
const tslint = require('gulp-tslint');
const rimraf = require('rimraf');
const es = require('event-stream');
const cp = require('child_process');
2015-10-14 11:18:34 +02:00
2017-03-14 14:12:55 +01:00
const project = gts.createProject('tsconfig.json');
2015-10-14 10:31:06 +02:00
2015-11-17 22:34:50 +01:00
function compile() {
2016-07-21 09:40:54 +02:00
const tsd = filter(['**', '!**/*.d.ts'], { restore: true });
2015-11-25 10:23:21 +01:00
2017-03-14 09:52:51 +01:00
const ts = project.src()
2016-07-21 09:40:54 +02:00
.pipe(tsd)
2017-03-14 14:12:55 +01:00
.pipe(tslint())
2016-07-21 09:40:54 +02:00
.pipe(tslint.report({ summarizeFailureOutput: true, emitError: false }))
.pipe(tsd.restore)
2017-03-14 09:52:51 +01:00
.pipe(sm.init())
2017-03-14 14:12:55 +01:00
.pipe(project());
2016-09-22 15:27:10 +02:00
2017-03-14 09:52:51 +01:00
const js = ts.js
.pipe(sm.write('.'));
const api = ts.dts
2016-09-22 15:27:10 +02:00
.pipe(filter('**/api.d.ts'));
2017-03-14 09:52:51 +01:00
const resources = gulp.src('src/**')
.pipe(filter(['**', '!**/*.ts']));
2016-09-22 15:27:10 +02:00
2017-03-14 09:52:51 +01:00
return es.merge(js, api, resources)
2015-10-14 10:31:06 +02:00
.pipe(gulp.dest('out'));
2015-11-17 22:34:50 +01:00
}
2015-10-14 10:31:06 +02:00
2016-07-21 09:40:54 +02:00
gulp.task('clean', cb => rimraf('out', cb));
2015-10-14 10:31:06 +02:00
gulp.task('compile', ['clean'], compile);
2015-11-17 22:34:50 +01:00
gulp.task('just-compile', compile);
2015-11-17 21:53:32 +01:00
2015-11-17 22:34:50 +01:00
function test(cb) {
2016-09-22 16:30:50 +02:00
const child = cp.spawn('mocha', ['--reporter=dot'], { stdio: 'inherit' });
2016-07-21 09:40:54 +02:00
child.on('exit', () => cb());
2015-11-17 22:34:50 +01:00
}
gulp.task('test', ['compile'], test);
gulp.task('just-test', ['just-compile'], test);
2015-11-17 21:53:32 +01:00
2016-07-21 09:40:54 +02:00
function watch(task) {
return () => gulp.watch(['src/**', 'typings/**'], [task]);
}
2015-11-25 10:23:21 +01:00
2016-07-21 09:40:54 +02:00
gulp.task('watch', ['compile'], watch('just-compile'));
gulp.task('watch-test', ['compile'], watch('just-test'));
2016-06-01 11:06:17 +02:00
2015-11-25 10:23:21 +01:00
gulp.task('default', ['watch']);