mirror of
https://github.com/infeeeee/dyn2py
synced 2025-12-16 22:16:18 +01:00
28 lines
708 B
Bash
28 lines
708 B
Bash
#!/bin/sh
|
|
|
|
# Create a list of files from staged files:
|
|
mapfile -t NEW_FILES <<<$(git diff --name-only --cached)
|
|
|
|
# Go through staged files:
|
|
for f in "${NEW_FILES[@]}"; do
|
|
|
|
# Export python files, only from Dynamo files.
|
|
# On Windows line ending is always CRLF, so remove CR with tr.
|
|
mapfile -t PY_FILES <<<$(dyn2py --force --filter dyn --loglevel HEADLESS "$f" | tr -d "\r")
|
|
|
|
# Check if something was exported:
|
|
if [[ "${PY_FILES[@]}" ]]; then
|
|
|
|
# Go through exported files:
|
|
for p in "${PY_FILES[@]}"; do
|
|
|
|
# Check if file exists:
|
|
if [ -f "$p" ]; then
|
|
|
|
# Stage file:
|
|
git add "$p"
|
|
fi
|
|
done
|
|
fi
|
|
done
|