mirror of
https://git.mills.io/prologic/zs.git
synced 2024-11-16 09:16:19 -05:00
26 lines
556 B
Bash
Executable File
26 lines
556 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ $# -ne 1 ]; then
|
|
printf "Usage: %s <path>\n" "$(basename "$0")"
|
|
exit 1
|
|
fi
|
|
|
|
modpath="$1"
|
|
modpath="${modpath%"/"}"
|
|
|
|
ext=".js"
|
|
if [ -n "$ZS_PRODUCTION" ]; then
|
|
ext=".min.js"
|
|
fi
|
|
|
|
echo "<script type=\"importmap\">"
|
|
{
|
|
find "$modpath" -type f -name '*.js' | while read -r file; do
|
|
name="${file#"$modpath"}"
|
|
name="${name#"/"}"
|
|
name="${name%.*}"
|
|
echo "${name}=./${modpath}/${name}${ext}"
|
|
done
|
|
} | jq -Rs '{ imports: split("\n") | [.[] | capture("^(?<name>[^=]+)=(?<src>.*)$") | {(.name): .src}] | add }'
|
|
echo "</script>"
|