Skip to content

Commit 031d768

Browse files
committed
Patch together JS generator script
The kind of code that doesn't make you feel pride, only a guilty sense of accomplishment.
1 parent 48b946a commit 031d768

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

generate-ipso-blob.pl

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#! /usr/bin/perl -w
2+
use 5.006;
3+
use strict;
4+
5+
system(q[
6+
perl -i -wpe'
7+
s/"module": "commonjs"/"module": "es2015"/
8+
' tsconfig.json
9+
]) == 0
10+
or die "tsconfig.json substitution failed: $?";
11+
12+
system(q[
13+
rm -rf lib/
14+
]) == 0
15+
or die "Removing lib/ failed: $?";
16+
17+
system(q[
18+
npx tsc > /dev/null
19+
]) == 512
20+
or die "Compiling with 'tsc' gave an unexpected status code: $?";
21+
22+
system(q[
23+
perl -i -wpe'
24+
s/"module": "es2015"/"module": "commonjs"/
25+
' tsconfig.json
26+
]) == 0
27+
or die "tsconfig.json back-substitution failed: $?";
28+
29+
-e "lib"
30+
or die "lib/ wasn't created as expected";
31+
32+
my @files = qw<
33+
value
34+
tokenize
35+
parse-value
36+
prims
37+
forms
38+
env
39+
expr
40+
parse-expr
41+
zip
42+
std-env
43+
kont
44+
state
45+
evaluate
46+
>;
47+
48+
my $path = "../website-ipso/ipso.js";
49+
50+
open my $OUT, ">", $path
51+
or die "Couldn't open $path for writing: $!";
52+
53+
for my $file (@files) {
54+
open my $IN, "<", "lib/src/$file.js"
55+
or die "Couldn't open lib/src/$file.js for reading: $!";
56+
while (<$IN>) {
57+
next if /^import /;
58+
if ($file eq "std-env") {
59+
next if /^export \{/;
60+
}
61+
else {
62+
s/^export \{/const $file = {/;
63+
}
64+
s/^export //;
65+
print {$OUT} $_;
66+
}
67+
close $IN;
68+
}
69+
70+
close $OUT;
71+

0 commit comments

Comments
 (0)