-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.mjs
50 lines (41 loc) · 1.16 KB
/
gulpfile.mjs
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
import { series } from "gulp";
import { deleteAsync } from "del";
import { exec as processExec } from "child_process";
/**
* Binds the standard output of the child process to the main process
*/
function exec(command) {
const childProcess = processExec(command);
childProcess.stdout?.on("data", console.info);
childProcess.stderr?.on("data", console.error);
return childProcess;
}
/**
* Runs the specified command using the local node modules bin folder
*/
function npmExec(command) {
const [executable, ...operands] = command.split(" ");
return exec(`node_modules/.bin/${executable} ` + operands.join(" "));
}
/**
* Remove all the generated files from the build
*/
export function clean() {
return deleteAsync(["lib/**", "lib", "tsconfig.tsbuildinfo"], { force: true });
}
/**
* Transpile the typescript code
*/
export function transpile() {
return npmExec("tsc");
}
/**
* Replace all aliases by the relative path
*/
export function convertPaths() {
return npmExec("tscpaths -p tsconfig.json -s ./src -o ./lib/src");
}
/**
* Build the project into the lib folder
*/
export const build = series(clean, transpile, convertPaths);