-
Notifications
You must be signed in to change notification settings - Fork 0
/
div.ts
35 lines (29 loc) · 872 Bytes
/
div.ts
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
import { globSync } from "glob";
import { divider } from "./lib/divider";
import { batchProcess } from "./lib/utils";
export async function divJs(
htmlSearchPatterns: string[],
destinationBasePath: string,
baseSearchPath: string = process.cwd(),
ignorePatterns: string[] = []
): Promise<void> {
ignorePatterns = [
...ignorePatterns,
"./node_modules/**",
`./${destinationBasePath}/**`,
];
const htmlFilePaths: string[] = globSync(htmlSearchPatterns, {
cwd: baseSearchPath,
absolute: true,
ignore: ignorePatterns,
});
const promises = new Array();
for (const htmlPath of htmlFilePaths) {
const proc = () => {
return divider(htmlPath, destinationBasePath);
};
promises.push(proc);
}
const MPP: number = 100; //memory per process
await batchProcess(promises, MPP);
}