-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfix-links.mjs
66 lines (61 loc) · 1.56 KB
/
fix-links.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { execSync } from "child_process";
import { lstatSync, readdirSync, statSync } from "fs";
import path from "path";
export const fixMacOsLinks = () => {
const files = readdirSync("ffmpeg/remotion/lib").filter((f) =>
f.endsWith(".dylib")
);
for (const file of files) {
const isSymbolicLink = lstatSync(
path.join(process.cwd(), `ffmpeg/remotion/lib/${file}`)
).isSymbolicLink();
if (isSymbolicLink) {
continue;
}
const sharedNames = execSync(`otool -L ${file}`, {
cwd: "ffmpeg/remotion/lib",
});
const matches = sharedNames.toString().match(/remotion\/lib\/(.*).dylib/g);
if (!matches) {
continue;
}
for (const match of matches) {
execSync(
"install_name_tool -id " +
match.replace("remotion/lib/", "") +
" " +
match,
{
cwd: "ffmpeg",
}
);
execSync(
`install_name_tool -change ${match} ${match.replace(
"remotion/lib/",
""
)} remotion/lib/${file}`,
{ cwd: "ffmpeg" }
);
}
}
const bins = readdirSync("ffmpeg/remotion/bin");
for (const bin of bins) {
const links = execSync(`otool -L ${bin}`, {
cwd: "ffmpeg/remotion/bin",
})
.toString()
.match(/remotion\/lib\/(.*).dylib/g);
if (!links) {
continue;
}
for (const link of links) {
execSync(
`install_name_tool -change ${link} ${link.replace(
"remotion/lib/",
""
)} remotion/bin/${bin}`,
{ cwd: "ffmpeg" }
);
}
}
};