build.zsh/build/livescript.zsh

57 lines
1.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

##
# The livescript backend makes a lot of assumptions about a *lot* of things.
# For example, it assumes youll build using browserify, that youll want
# to minify using babel, and so on.
#
# Youll probably want to override or redefine some of those functions in
# your project.zsh, which kinda sucks but is also difficult to avoid with…
# well… you know, JavaScript.
##
function LSC {
echo "${fg_bold[blue]} LSC > ${fg_bold[white]}$@${reset_color}"
}
function BUN {
echo "${fg_bold[green]} BUN > ${fg_bold[white]}$@${reset_color}"
}
function MIN {
echo "${fg_bold[red]} MIN > ${fg_bold[white]}$@${reset_color}"
}
function livescript.prelude {
: ${install[$target]:=\$(SHAREDIR)/$package}
: ${chmod[$target]:=644}
}
function livescript.build {
write "${target}: ${target%.js}.bundle.js $(dirdep $target)"
write "\t@echo '$(MIN ${target%.js}.js)'"
write "\t${Q}npx babel --minified ${target%.js}.bundle.js -o ${target}"
write "\n"
write "${target%.js}.bundle.js: ${sources[$target]} ${depends[$target]} $(dirdep $target)"
write "\t@echo '$(BUN ${target%.js}.bundle.js)'"
write "\t${Q}npx browserify -t browserify-livescript ${sources[$target]} -o ${target%.js}.bundle.js"
write "\n"
}
function livescript.clean {
write "${target}.clean:"
for file in ${target} ${target%.js}.bundle.js; do
write "\t@echo '$(RM ${file})'"
write "\t${Q}rm -f ${file}"
done
write "\n"
}
function livescript.install {
binary.install "$@"
}
function livescript.uninstall {
binary.uninstall "$@"
}