-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
62 lines (54 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
// Copyright (c) 2020, 2021, 2022, 2023 Luca Cappa
// Released under the term specified in file LICENSE.txt
// SPDX short identifier: MIT
const gulp = require('gulp');
const path = require('path');
const install = require('gulp-install');
const ts = require("gulp-typescript");
const sourcemaps = require("gulp-sourcemaps");
const eslint = require('gulp-eslint');
const jest = require('gulp-jest').default;
var installPackages = function () {
return gulp.src([
"./package.json"]).pipe(install());
}
var build = function () {
tsProject = ts.createProject('./tsconfig.json');
return tsProject.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(path.join('build')))
}
var eslinter = function () {
// Linting only files of this action, avoid any linting of the embedded actions/cache
// in the git subtree.
return gulp.src(['src/**/*.ts'])
// eslint() attaches the lint output to the "eslint" property
// of the file object so it can be used by other modules.
.pipe(eslint())
// eslint.format() outputs the lint results to the console.
// Alternatively use eslint.formatEach() (see Docs).
.pipe(eslint.format())
// To have the process exit with an error code (1) on
// lint error, return the stream and pipe to failAfterError last.
.pipe(eslint.failAfterError());
}
var test = function () {
return gulp.src('__tests__').pipe(jest({
"preprocessorIgnorePatterns": [
"<rootDir>/dist/",
"<rootDir>/node_modules/"
],
"testPathIgnorePatterns": [
"<rootDir>/actions/"
],
"automock": false
}));
};
gulp.task('test', test);
gulp.task('eslint', eslinter);
gulp.task('build', build);
gulp.task('installPackages', installPackages);
// 'test' must not be part of the 'default' target, as it is started explicitly *after* ncc has been run by the package.json run script.
gulp.task('default', gulp.series('installPackages', 'eslint', 'build'));