mirror of
https://git.mills.io/prologic/zs
synced 2024-11-22 13:26:11 +03: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>"
|