Make the unit.js.tpl actually work with the new path of the files, remove silly printf hack for indentation by allowing only one indentation at a time and make sure empty lines don't get indented
This commit is contained in:
parent
fcf5bdc55b
commit
f0bd320683
1 changed files with 25 additions and 4 deletions
29
unit.js.tpl
29
unit.js.tpl
|
@ -2,15 +2,36 @@
|
|||
|
||||
indent()
|
||||
{
|
||||
local tabs="$(printf '\t%.0s' `seq 1 $1`)"
|
||||
sed "s|^|${tabs}|"
|
||||
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 {
|
||||
$(echo "${@}" | sed -e 's| |,\n|g' -e 's|\([^.\n]\+\)\.js|\u\1: \u\1|g' | indent 2)
|
||||
$(printf "${MODULES}" | sed -e 's|:|,\n|g' -e 's|[^,\n]\+|&: &|g' | indent | indent)
|
||||
};
|
||||
$(cat "${@}" | indent 1)
|
||||
$(for file in "${@}"; do includeModule "${file}"; done | indent)
|
||||
})();
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue