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

nuxfs: Added definition capture support.

Signed-off-by: Tony Tkacik <tonydamage@gmail.com>
This commit is contained in:
Tony Tkáčik 2016-12-02 15:19:18 +01:00
parent fbf020f0d3
commit 0911f06f83
2 changed files with 60 additions and 1 deletions

View file

@ -11,6 +11,7 @@ nux.include nuxfs
nux.include nuxfs.dsl
GIT_BIN=$(which git)
## check - Verifies that directory matches nuxfs specification
function task.check {
link.exists() {
@ -137,6 +138,64 @@ function task.info {
fi;
}
function nuxfs.dsl.capture.dir {
local CDIR=$1;
local LEVEL=$2;
nux.log debug "Inspecting directory $CDIR";
if [ -e "$RELATIVE/$SUFFIX" ]; then
return;
fi;
pushd "$CDIR" > /dev/null;
for file in ./* ; do
nuxfs.dsl.capture.file "$file" ".";
done;
popd > /dev/null;
}
function nuxfs.dsl.capture.file {
local file=$1;
local pdir=$2;
local RELATIVE=$(realpath -ms "$file" --relative-to "$pdir");
local ADDARGS="";
local TYPE="";
nux.log debug "Inspecting $file , Relative path is $RELATIVE";
if [ -h "$RELATIVE" ]; then
TYPE="link";
ADDARGS="\"$(readlink "$RELATIVE")\""
elif [ -d "$RELATIVE" -a -d "$RELATIVE/.git" ]; then
TYPE=git;
pushd "$RELATIVE" > /dev/null;
ADDARGS="\"$($GIT_BIN remote get-url origin)\""
popd > /dev/null;
elif [ -d "$RELATIVE" ]; then
TYPE="dir";
fi;
if [ "$TYPE" ]; then
echo -e "${LEVEL}$TYPE \"$RELATIVE\" $ADDARGS";
fi;
if [ "$TYPE" = "dir" -a "$LEVEL" != " " ]; then
nuxfs.dsl.capture.dir "$RELATIVE" "${LEVEL} "
echo "${LEVEL}enddir";
fi;
}
## capture - Captures current directory to nuxfs syntax
function task.capture {
if [ $# -eq 0 ]; then
nuxfs.dsl.capture.dir .
else
for file in "$@" ; do
nuxfs.dsl.capture.file "$file" .;
done;
fi
}
function nuxfs.template.list {
echo "Available templates:";
pushd $TEMPLATE_DIR > /dev/null;

View file

@ -101,7 +101,7 @@ function nuxfs.dsl.execute {
nuxfs.dsl.keywords
local DEF="$1";
local DIR="$2";
NESTED_DIR="$(realpath "$3")/";
NESTED_DIR="$(realpath -s "$3")/";
nux.log debug "Working Directory: $DIR , Nested Directory: $NESTED_DIR"
declare -a DIR_ARRAY
DIR_ARRAY[0]=$DIR