This repository has been archived by the owner on Feb 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
75 lines (69 loc) · 1.96 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
'use strict';
var concat = require('gulp-concat'),
eslint = require('gulp-eslint'),
gulp = require('gulp'),
insert = require('gulp-insert'),
mocha = require('gulp-mocha'),
path = require('path'),
runSequence = require('run-sequence'),
sourcemaps = require('gulp-sourcemaps'),
typescript = require('gulp-typescript');
/**
* Default Tasks
*/
gulp.task('default', function (cb) {
runSequence('lint', 'mocha', cb);
});
/**
* Run ESLint
*/
gulp.task('lint', function () {
gulp.src(['*.js', 'lib/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
/**
* Run Mocha
*/
gulp.task('mocha', function () {
return gulp.src(['test/**/*.js', '!test/fixtures/**/*.js'], {'read': false})
// gulp-mocha needs filepaths so you can't have any plugins before it
.pipe(mocha({'reporter': 'spec'}));
});
/**
* Compile Custom Vorlon
*/
gulp.task('compile-vorlon', function () {
return gulp.src(['vendor/custom-vorlon/rules/**/*.ts', 'vendor/custom-vorlon/*.ts'])
.pipe(sourcemaps.init())
.pipe(typescript({
'declarationFiles': true,
'noExternalResolve': true,
'target': 'ES5'
}))
.pipe(concat('vendor/vorlon.js'))
.pipe(insert.append('module.exports = VORLON;\n'))
.pipe(sourcemaps.write({
'includeContent': false,
// Return relative source map root directories per file.
'sourceRoot': function (file) {
var sourceFile = path.join(file.cwd, file.sourceMap.file);
return path.relative(path.dirname(sourceFile), file.cwd);
}
}))
.pipe(gulp.dest('.'));
});
/**
* Generate Vorlon TypeScript Definition File
*/
gulp.task('gen-vorlon-dts', function () {
var tsResult = gulp.src(['vendor/custom-vorlon/rules/**/*.ts', 'lib/custom-vorlon/*.ts'])
.pipe(concat('vendor/vorlon.d.ts'))
.pipe(typescript({
'declarationFiles': true,
'noExternalResolve': true,
'target': 'ES5'
}));
return tsResult.dts.pipe(gulp.dest('.'));
});