28 lines
431 B
Bash
Executable File
28 lines
431 B
Bash
Executable File
#!/bin/sh
|
|
|
|
importmap="$1"
|
|
tmp="$(mktemp)"
|
|
|
|
awk '
|
|
BEGIN {
|
|
s="<!-- start importmap -->"
|
|
e="<!-- end importmap -->"
|
|
}
|
|
|
|
FILENAME != "index.html" {
|
|
d=d $0 "\n"
|
|
next
|
|
}
|
|
$0 == s || $0 == e { print }
|
|
$0 == s,$0 == e {
|
|
if(d) {
|
|
print "<script type=\"importmap\">"
|
|
printf d;
|
|
d = ""
|
|
print "</script>"
|
|
}
|
|
next
|
|
}
|
|
{ print }
|
|
' "$importmap" index.html > "$tmp" \
|
|
&& mv "$tmp" index.html |