UNPKG

1.05 kBapplication/x-shView Raw
1#!/usr/bin/env bash
2
3BASEDIR=$(dirname "$0")
4
5source ${BASEDIR}/src/index.sh
6
7# Pre-setup "curl" to allow "@freak2geek/script-helpers" import
8if ! hasCurl; then
9 setupCurl
10fi
11
12distFilename="script-helpers"
13packageName="@freak2geek/script-helpers"
14
15printf "${BLUE}[-] Building \"${packageName}\"...${NC}\n"
16
17packageDist="${PROJECT_F2G_SCRIPTS_PATH}/dist/${distFilename}.sh"
18packageTmp="${PROJECT_F2G_SCRIPTS_PATH}/dist/tmp.sh"
19
20# Remove existing dist script
21[[ -f ${packageDist} ]] && rm ${packageDist}
22
23# Append all the scripts together on a temporary file
24for filename in ${PROJECT_F2G_SCRIPTS_PATH}/src/*.sh; do
25 cat $filename >> ${packageTmp}
26done
27# Remove imports and shebang lines
28sedi '/^source .*/d' ${packageTmp}
29sedi '/\#\!\/usr\/bin\/env bash/d' ${packageTmp}
30
31# Include shebang line and all the scripts
32echo "#!/usr/bin/env bash" >> ${packageDist}
33# Compile rest of the code
34cat ${packageTmp} >> ${packageDist}
35
36# Remove temporary file
37[[ -f ${packageTmp} ]] && rm ${packageTmp}
38
39printf "${GREEN}[✔] Built \"${packageName}\"${NC}\n"