Thought cabinet
This commit is contained in:
28
task/inject-importmap
Executable file
28
task/inject-importmap
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user