mirror of
https://github.com/tonydamage/nux-env.git
synced 2025-12-11 13:24:28 +01:00
nuxfs: Added support for specifying path.
Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
parent
ff642e4222
commit
fbf020f0d3
3 changed files with 31 additions and 10 deletions
19
bin/nuxfs
19
bin/nuxfs
|
|
@ -51,7 +51,7 @@ function task.check {
|
|||
def.notexists() {
|
||||
nuxfs.error "$1" "does not exists".
|
||||
}
|
||||
nuxfs.initcfg
|
||||
nuxfs.initcfg "$@"
|
||||
nuxfs.dsl.execute "$NUXFS_DEF" "$NUXFS_DEF_DIR" "$WORKDIR_ABSOLUTE"
|
||||
}
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ function task.apply {
|
|||
popd > /dev/null;
|
||||
}
|
||||
|
||||
nuxfs.initcfg
|
||||
nuxfs.initcfg "$@"
|
||||
nuxfs.dsl.execute "$NUXFS_DEF" "$NUXFS_DEF_DIR" "$WORKDIR_ABSOLUTE"
|
||||
}
|
||||
|
||||
|
|
@ -152,14 +152,23 @@ function nuxfs.template.list {
|
|||
|
||||
function nuxfs.initcfg {
|
||||
|
||||
WORKDIR=$1;
|
||||
if [ -n "$WORKDIR" ]; then
|
||||
WORKDIR=$WORKDIR
|
||||
else
|
||||
WORKDIR=$(pwd);
|
||||
NUXFS_DEF=$(nuxfs.closest $SUFFIX);
|
||||
fi;
|
||||
|
||||
nux.log debug Target: $WORKDIR
|
||||
|
||||
NUXFS_DEF=$(nuxfs.closest $SUFFIX "$WORKDIR");
|
||||
|
||||
if [ "$NUXFS_DEF" = "" ]; then
|
||||
nuxfs.error $(pwd) "No nuxfs configuration found."
|
||||
return;
|
||||
fi;
|
||||
NUXFS_DEF_DIR=$(dirname $NUXFS_DEF);
|
||||
WORKDIR_RELATIVE=$(realpath "$WORKDIR" --relative-to "$NUXFS_DEF_DIR")
|
||||
WORKDIR_ABSOLUTE=$(realpath "$WORKDIR")
|
||||
WORKDIR_RELATIVE=$(realpath -ms "$WORKDIR" --relative-to "$NUXFS_DEF_DIR")
|
||||
WORKDIR_ABSOLUTE=$(realpath -ms "$WORKDIR")
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ function nuxfs.dsl.command {
|
|||
if [[ "$NESTED_DIR" = "$localFile"* || "$localFile" = "$NESTED_DIR"* ]]; then
|
||||
nux.log debug $localFile is affected by $NESTED_DIR;
|
||||
|
||||
if [[ "$NESTED_DIR" = "$localFile/" || "$localFile" = "$NESTED_DIR"* ]]; then
|
||||
NUXFS_TARGET_FOUND=1;
|
||||
fi
|
||||
|
||||
if nuxfs.file.exists "$localFile"; then
|
||||
nux.log debug "File $NC_White$localFile$NC_No exits";
|
||||
exec.if.function $CMD.exists def.exists "$localFile" "$@";
|
||||
|
|
@ -102,7 +106,11 @@ function nuxfs.dsl.execute {
|
|||
declare -a DIR_ARRAY
|
||||
DIR_ARRAY[0]=$DIR
|
||||
if test -e "$DEF"; then
|
||||
NUXFS_TARGET_FOUND=0;
|
||||
source "$DEF";
|
||||
if [ $NUXFS_TARGET_FOUND = 0 ]; then
|
||||
nuxfs.warning "$3" "Does not have definition in $DEF";
|
||||
fi
|
||||
else
|
||||
nuxfs.error "$DEF" Definition file does not exists.
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -2,18 +2,22 @@ function nuxfs.relative {
|
|||
echo "$(nuxfs.dir.get)/$1"
|
||||
}
|
||||
|
||||
function nuxfs.relative-to-pwd {
|
||||
realpath -s "$1" --relative-to "$(realpath "$(pwd)")"
|
||||
}
|
||||
|
||||
function nuxfs.error {
|
||||
local filename=$1; shift;
|
||||
local filename=$(nuxfs.relative-to-pwd "$1"); shift;
|
||||
nux.echo.error "$filename"$NC_No: $*;
|
||||
}
|
||||
|
||||
function nuxfs.warning {
|
||||
local filename=$1; shift;
|
||||
local filename=$(nuxfs.relative-to-pwd "$1"); shift;
|
||||
nux.echo.warning "$filename"$NC_No: $*;
|
||||
}
|
||||
|
||||
function nuxfs.info {
|
||||
local filename=$1; shift;
|
||||
local filename=$(nuxfs.relative-to-pwd "$1"); shift;
|
||||
echo -e $NC_White"$filename"$NC_No: $*;
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +40,7 @@ function nuxfs.file.exists {
|
|||
|
||||
function nuxfs.closest {
|
||||
cmd=$1;
|
||||
cdir=$(pwd);
|
||||
cdir=$2;
|
||||
nux.log trace "Searching in: " $cdir;
|
||||
until [ -e "$cdir/$1" -o "$cdir" == "/" ]; do
|
||||
cdir=$(dirname "$cdir");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue