-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
62 lines (54 loc) · 1.63 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
var copy = require('gulp-copy');
var del = require('del');
var gulp = require('gulp');
var merge = require('merge2');
var path = require('path');
var sourcemaps = require('gulp-sourcemaps');
var ts = require('gulp-typescript');
var vinylPaths = require('vinyl-paths');
var tsProject = ts.createProject({
declarationFiles: true,
module: 'commonjs',
noEmitOnError: true,
noExternalResolve: false,
noImplicitAny: true
});
// All files created and used for building are in here
buildPath = 'build/';
// Development build path
devRootPath = path.join(buildPath, 'dev/');
devPath = path.join(devRootPath, 'node-chrome-runner/');
// Typescript src code in the development path
tsPath = path.join(devPath, '**/*.ts');
// Distribution build path
distRootPath = path.join(buildPath, 'dist');
distPath = path.join(distRootPath, 'node-chrome-runner/');
var tasks = {
clean: 'clean',
dist: 'dist',
copy_src: 'copy-src',
tsc: 'tsc'
};
gulp.task(tasks.copy_src, function() {
return gulp.src(['src/**/*'])
.pipe(copy(devPath, { prefix: 1 }));
});
gulp.task(tasks.tsc, [tasks.copy_src], function() {
var tsResult = gulp.src([tsPath])
.pipe(sourcemaps.init())
.pipe(ts(tsProject));
return merge([
tsResult.dts
.pipe(gulp.dest(devPath)),
tsResult.js
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(devPath))]);
});
gulp.task(tasks.clean, function(cb) {
del([devRootPath, distRootPath], cb);
});
gulp.task(tasks.dist, [tasks.tsc], function() {
return gulp.src([path.join(devPath, '**/*')])
.pipe(copy(distPath, { prefix: devPath.split(path.sep).length }));
});
gulp.task('default', [tasks.tsc]);