Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
chore: move printf into helper fns
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed May 23, 2021
1 parent e59e9a9 commit 15db452
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
6 changes: 4 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

source $(dirname "$0")/helpers.sh

rm -rf dist
rollup -c

# Unify types into one file
mv dist/types/lucia.d.ts dist/lucia.d.ts
rm -rf dist/types

info "Dist: `ls -xm -d dist/*`"
6 changes: 3 additions & 3 deletions scripts/dev.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

source $(dirname "$0")/helpers.sh

content="<!DOCTYPE html>
<html lang=\"en\">
<head>
Expand All @@ -13,11 +15,9 @@ content="<!DOCTYPE html>
<!-- Your code here -->
</body>
</html>"
BLUE_COLOR='\033[0;34m'
RESET_COLOR="\u001b[39m"

if [ ! -f index.html ]; then
echo -e "$content" >> index.html
printf "${BLUE_COLOR}β“˜ Couldn't find an \`index.html\` file at root, creating one for you..${RESET_COLOR}\n"
info "Couldn't find an \`index.html\` file at root, creating one for you..."
fi
npx vite --host
23 changes: 23 additions & 0 deletions scripts/helpers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
YELLOW_COLOR="\u001b[33m"
GREEN_COLOR="\033[0;32m"
RED_COLOR='\033[0;31m'
BLUE_COLOR='\033[0;34m'
RESET_COLOR="\u001b[39m"
SPACER=' '

function pending {
printf "${YELLOW_COLOR}⚠ $1${RESET_COLOR}"
}

function info {
printf "${BLUE_COLOR}β“˜ $1${RESET_COLOR}\n"
}

function success {
printf "\r${GREEN_COLOR}βœ“ $1${RESET_COLOR}${SPACER}\n"
}

function fail {
printf "\r${RED_COLOR}βœ— Error during $1. Run \`$2\`.${RESET_COLOR}${SPACER}\n";
exit 1;
}
21 changes: 6 additions & 15 deletions scripts/release.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
#!/bin/bash

YELLOW_COLOR="\u001b[33m"
GREEN_COLOR="\033[0;32m"
RED_COLOR='\033[0;31m'
BLUE_COLOR='\033[0;34m'
RESET_COLOR="\u001b[39m"
SPACER=" "
source $(dirname "$0")/helpers.sh

function fail {
printf "\r${RED_COLOR}βœ— Error during $1. Run \`$2\`.${RESET_COLOR}\n";
exit 1;
}

printf "${YELLOW_COLOR}⚠ Checking for errors...${RESET_COLOR}"
pending "Checking for errors..."
source scripts/check.sh &>/dev/null || fail "checks" "sh scripts/check.sh"
printf "\r${GREEN_COLOR}βœ“ No errors found.${RESET_COLOR}${SPACER}\n"
printf "${YELLOW_COLOR}⚠ Building distribution bundles...${RESET_COLOR}"
success "No errors found."
pending "Building distribution bundles..."
source scripts/check.sh &>/dev/null || fail "build" "yarn build"
printf "\r${GREEN_COLOR}βœ“ Built distribution bundles.${SPACER}${RESET_COLOR}\n${BLUE_COLOR}β“˜ Run \`np\` to publish.${RESET_COLOR}\n"
success "Built distribution bundles."
info "Run \`np\` to publish."

0 comments on commit 15db452

Please sign in to comment.