-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathinstallPrebuilds.ts
More file actions
76 lines (53 loc) · 1.55 KB
/
installPrebuilds.ts
File metadata and controls
76 lines (53 loc) · 1.55 KB
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
67
68
69
70
71
72
73
74
75
76
import fs from "fs"
import path from "path"
function argon2() {
const argon2PrebuildsPath = path.join(__dirname, "prebuilds", "argon2")
if (!fs.existsSync(argon2PrebuildsPath)) {
console.error("Prebuilds directory does not exist:", argon2PrebuildsPath)
process.exit(1)
}
const prebuilds = fs.readdirSync(argon2PrebuildsPath)
if (prebuilds.length === 0) {
console.error("No prebuilds found in directory:", argon2PrebuildsPath)
process.exit(1)
}
console.log(`Found ${prebuilds.length} prebuilds in ${argon2PrebuildsPath}`)
const destinationPath = path.join(__dirname, "nodejs-assets", "nodejs-project", "node_modules", "argon2", "prebuilds")
if (!fs.existsSync(destinationPath)) {
fs.mkdirSync(destinationPath, {
recursive: true
})
console.log(`Created destination directory: ${destinationPath}`)
}
fs.rmSync(destinationPath, {
recursive: true,
force: true
})
fs.mkdirSync(destinationPath, {
recursive: true
})
prebuilds.forEach(prebuild => {
const source = path.join(argon2PrebuildsPath, prebuild)
if (!fs.statSync(source).isDirectory()) {
return
}
const dest = path.join(destinationPath, prebuild)
if (fs.existsSync(dest)) {
fs.rmSync(dest, {
recursive: true,
force: true
})
console.log(`Removed existing prebuild directory: ${dest}`)
}
fs.cpSync(source, dest, {
recursive: true
})
console.log(`Copied ${prebuild} to ${destinationPath}`)
})
}
function main() {
console.log("Installing prebuilds...")
argon2()
console.log("Prebuilds installation completed successfully.")
}
main()