A collection of JS modules to meet basic needs for web clients.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
530 B

#!/bin/sh
indent()
{
sed "s|^\(.\)|\t\1|"
}
moduleName()
{
local fileName="${1##*/}"
printf "${fileName%.*}"
}
MODULES=""
for file in "${@}"
do
MODULES="${MODULES}:$(moduleName "${file}")"
done
MODULES="${MODULES#:}"
includeModule()
{
cat <<EOF
function $(moduleName "${1}")() {
$(cat "${1}" | indent)
}
EOF
}
cat <<EOF
var unitJS = (function() {
return {
$(printf "${MODULES}" | sed -e 's|:|,\n|g' -e 's|[^,\n]\+|&: &|g' | indent | indent)
};
$(for file in "${@}"; do includeModule "${file}"; done | indent)
})();
EOF