Skip to content

Commit 0bfea0b

Browse files
committed
fix: line exit, trigger, mktemp
1 parent 0cd0076 commit 0bfea0b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

please

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ declare -A EVENTS
1515
FULL=`readlink -f $0` # fullpath
1616
PLIZ=`basename $0` # name
1717

18-
line() { echo -e "\e[${3:-0};$2m$1\e[0m" && [[ "$4" != "" ]] && exit $4; }
19-
error() { line "$1" 31 0 ${2:-}; }
20-
ok() { line "${1:- Done}" 32 0 ${2:-}; }
21-
info() { line "$1" 33 0 ${2:-}; }
22-
comment() { line "$1" 30 1 ${2:-}; }
23-
18+
line() { echo -e "\e[${3:-0};$2m$1\e[0m"; if [[ "$4" != "" ]]; then exit $4; fi }
19+
error() { line "$1" 31 0 $2; }
20+
ok() { line "${1:- Done}" 32 0 $2; }
21+
info() { line "$1" 33 0 $2; }
22+
comment() { line "$1" 30 1 $2; }
23+
# info 1
2424
qgit() { git "$@" &>> $TMP_LOG; }
2525

2626
# github api
@@ -198,16 +198,17 @@ publish-npm()
198198
# trigger event
199199
trigger() # $1 = event
200200
{
201-
local EVENT="$1" CMD="${EVENTS[$EVENT]}"
201+
local CMD="${EVENTS[$1]}"
202202
if [[ "$CMD" != "" ]]; then
203-
echo -e "$(info Running) $(ok "$EVENT")\n$(comment "> $CMD")"
203+
echo -e "$(info Running) $(ok "$1")\n$(comment "> $CMD")"
204204
eval "CMD=\"${CMD//{/\${}\"" && eval "$CMD"
205205
fi
206206
}
207207
208208
GCFMT="%s (%an)" # git commit log format
209209
REPO=`git config --get remote.origin.url | sed -e 's/[email protected]://;s/https:\/\/github.com\///;s/.git//'`
210210
211+
# load events
211212
[[ -f ./please.json ]] && eval $(cat ./please.json | jq -r 'to_entries|map("EVENTS[\(.key)]=\"\(.value)\"")|.[]')
212213
213214
# argv parsing
@@ -231,6 +232,7 @@ while [[ $# -gt 0 ]]; do
231232
done
232233
233234
[[ $REPO ]] || error "$(pwd) is not git repo" 1
235+
[[ -z "$GH_AUTH_TOKEN" ]] && error "GH_AUTH_TOKEN missing" 1
234236
235237
GPUSH=0 # git push pending
236238
MAJOR=${MAJOR:-0} # bump major
@@ -239,9 +241,7 @@ VFILE=${VFILE:-0} # create version file
239241
CHLOG=${CHLOG:-0} # create changelog file
240242
YES=${YES:-0} # assume yes
241243
242-
[[ -z "$GH_AUTH_TOKEN" ]] && error "GH_AUTH_TOKEN missing" 1
243-
244-
GH_REPO="github.com/repos/$REPO" TMP_LOG=`mktemp -p PLZ.XXXXXXXXXX`
244+
GH_REPO="github.com/repos/$REPO" TMP_LOG=`mktemp -t PLZ.XXXXXXXXXX`
245245
ok "Repository $REPO" && info "Log file $TMP_LOG"
246246
247247
DEPLOY_BRANCH="${DEPLOY_BRANCH:-master}"

0 commit comments

Comments
 (0)