This repository has been archived by the owner on Feb 9, 2023. It is now read-only.
/
gulpfile.js
66 lines (58 loc) · 1.66 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
const gulp = require("gulp");
const { genIndex, Packager } = require("@vesta/devmaid");
const { execSync } = require("child_process");
let pkgr = new Packager({
root: __dirname,
src: "src",
targets: ["es6"],
files: [".npmignore", "LICENSE", "README.md"],
publish: "--access=public",
transform: {
package: (json, target) => {
delete json.private;
return false;
},
tsconfig: function(tsconfig, target, isProduction) {
// tsconfig.compilerOptions.target = target;
}
}
});
function indexer() {
genIndex("src");
return Promise.resolve();
}
function watch() {
gulp.watch(["src/**/*", "!src/**/index.ts"], indexer);
return Promise.resolve();
}
const tasks = pkgr.createTasks();
module.exports = {
default: gulp.series(indexer, tasks.default, watch),
publish: gulp.series(indexer, tasks.deploy, tasks.publish),
test: test,
}
// test section
let isWatching = false;
function test() {
if (!isWatching) {
isWatching = true;
gulp.watch(["test/**/*.ts", "src/**/*.ts"], test);
}
return exec(`npx tsc --project ${__dirname}/tsconfig.test.json`, `${__dirname}/test`)
.then((error) => {
// console.error(error);
exec("npx jest test", `${__dirname}/test`)
})
.then((error) => {
// console.error(error);
})
function exec(command, wd) {
try {
console.log(`\n\n\t> ${command}\n`);
execSync(command, { cwd: wd, stdio: "inherit" });
return Promise.resolve();
} catch (error) {
return Promise.resolve(error);
}
}
}