1
1
Fork 0
mirror of https://github.com/tonydamage/nux-env.git synced 2025-12-11 13:24:28 +01:00

nux-runner: Added support ti be included as source.

Signed-off-by: Tony Tkacik <atkacik@brocade.com>
This commit is contained in:
Tony Tkacik 2016-12-01 16:17:33 +01:00
parent 8aff47bd72
commit 1737416a72
2 changed files with 21 additions and 7 deletions

View file

@ -6,10 +6,13 @@
### (similar in usage such as apt, git).
###
readonly NUX_RUNNER=$0;
readonly NUX_RUNNER_BIN_DIR=$(dirname $(realpath ${BASH_SOURCE[0]}))
source $NUX_RUNNER_BIN_DIR/../inc/nux-base.inc.sh
readonly NUX_RUNNER=$NUX_RUNNER_BIN_DIR/nux-runner;
nux.include nux-runner
##
@ -45,8 +48,16 @@ task.() {
task.help
}
readonly NUX_SCRIPT=$1;
shift; # Determines script
if [ "$NUX_RUNNER" = "$0" ]
then
readonly NUX_SCRIPT=$1;
shift;
else
readonly NUX_SCRIPT=$0;
readonly NUX_NO_INCLUDE="no include";
fi
# Determines script
readonly NUX_SCRIPTNAME=$(basename $NUX_SCRIPT)
nux-runner.run "$@"

View file

@ -2,13 +2,16 @@
nux-runner.run() {
TASK=$1; shift; # Determines task
if nux.check.function task.$TASK ; then
if nux.check.function task.$TASK
then
nux.log debug "Running task: $TASK";
task.$TASK "$@" # Runs task
else
if [ -z "$NUX_NO_INCLUDE" ]
then
nux.log debug "Including script: $NUX_SCRIPT"
source $NUX_SCRIPT; # Includes script
fi
if nux.check.function task.$TASK ; then
nux.log debug "Running task: $TASK";
task.$TASK "$@" # Runs task