Skip to content

Commit

Permalink
fixed #335 don't trigger hooks from API
Browse files Browse the repository at this point in the history
  • Loading branch information
alexylem committed Feb 4, 2017
1 parent 8c85472 commit 2b82502
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion jarvis-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ LISTEN_COMMAND () {
PLAY sounds/timeout.wav
sleep 1 # BUG here despite timeout mic still busy can't rec again...
bypass=false
source hooks/exiting_cmd
$jv_json || source hooks/exiting_cmd # don't trigger hooks if API
order='' # clean previous order
commands="$(jv_get_commands)" # in case we were in nested commands
break 2
Expand Down
5 changes: 3 additions & 2 deletions jarvis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ EOM
exit
fi

# don't trigger hooks from API
$jv_json || source hooks/program_startup

# if -s argument provided, just say it & exit (used in jarvis-events)
if [[ "$just_say" != false ]]; then
say "$just_say"
Expand Down Expand Up @@ -490,8 +493,6 @@ if [ "$just_execute" == false ]; then
fi
fi

source hooks/program_startup

# Include installed plugins
shopt -s nullglob
for f in plugins/*/config.sh; do source $f; done # plugin configuration
Expand Down
14 changes: 9 additions & 5 deletions utils/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,14 @@ jv_kill_jarvis () {
jv_exit () {
local return_code=${1:-0}

$verbose && jv_debug "DEBUG: program exit handler"
source hooks/program_exit $return_code

$jv_json && echo "]"
# If using API, terminate json table output
if $jv_json; then
echo "]"
else
# If not using API, trigger program exit hook
$verbose && jv_debug "DEBUG: program exit handler"
source hooks/program_exit $return_code
fi

# termine child processes (ex: HTTP Server from Jarvis API Plugin)
local jv_child_pids="$(jobs -p)"
Expand All @@ -271,7 +275,7 @@ jv_exit () {
fi

# make sure the lockfile is removed when we exit and then claim it
#[ "$(cat $lockfile)" == $$ ] && rm -f $lockfile # to test tested further
#[ "$(cat $lockfile)" == $$ ] && rm -f $lockfile # to be tested further
#[ "$just_execute" == false ] && rm -f $lockfile # https://github.com/alexylem/jarvis-api/issues/3
exit $return_code
}
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
17.01.26
17.02.04

0 comments on commit 2b82502

Please sign in to comment.