/
pak-extractor.ts
49 lines (48 loc) · 1019 Bytes
/
pak-extractor.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { spawn } from "../utils"
export interface PakExtrakterArgs {
exe?: string
input: string
output: string
hashFile?: string
decompressAzcs?: boolean
fixLua?: boolean
threads?: number
exclude?: string[]
include?: string[]
}
export async function pakExtractor({
exe,
input,
output,
hashFile,
decompressAzcs,
fixLua,
threads,
exclude,
include,
}: PakExtrakterArgs) {
// https://github.com/new-world-tools/new-world-tools
const tool = exe || 'pak-extracter.exe'
const args = [`-input`, input, `-output`, output]
if (hashFile) {
args.push(`-hash`, hashFile)
}
if (exclude) {
args.push(`-exclude`, exclude.map((it) => `(${it})`).join('|'))
}
if (include) {
args.push(`-include`, include.map((it) => `(${it})`).join('|'))
}
if (decompressAzcs) {
args.push(`-decompress-azcs`)
}
if (fixLua) {
args.push(`-fix-luac`)
}
if (threads) {
args.push(`-threads`, String(threads))
}
await spawn(tool, args, {
stdio: 'inherit',
})
}