forked from chris-rudmin/opus-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
inliner.pl
executable file
·28 lines (24 loc) · 974 Bytes
/
inliner.pl
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
#!/perl
my $wasmFilePath = 'dist-unminified/encoderWorker.wasm';
my $base64FilePath = './base64.txt';
my $encoderFilePath = './dist-unminified/encoderWorker.js';
my $inlineEncoderFilePath = './src/encoderWorker.inline.js';
`base64 $wasmFilePath > $base64FilePath`;
open(BASE64, $base64FilePath) or die "Error: no file found.";
(my $base64 = <BASE64>) =~ s/^\s+|\s+$//g;
open(SOURCE, $encoderFilePath);
open(RESULT, ">$inlineEncoderFilePath");
while (<SOURCE>) {
if (index($_, "encoderWorker.wasm") != -1) {
if (index($_, "var wasmBinaryFile = ") != -1) {
printf RESULT ("var wasmBinaryFile = dataURIPrefix + '%s';\n", $base64);
} elsif (index($_, "wasmBinaryFile = ") != -1) {
printf RESULT ("wasmBinaryFile = dataURIPrefix + '%s';\n", $base64);
} else {
die "No pattern found! Check the content of " . $encoderFilePath . "!"
}
} else {
print RESULT $_;
}
}
unlink $base64FilePath;