Skip to content

Commit 6de54a3

Browse files
committed
Added to git plop lk module name env
1 parent 2933a9a commit 6de54a3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bin/git-plop

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ workdir=$(jq -r '.workdir' "$plop_json_path")
2929

3030
src_dir="$plop_json_dir/$src"
3131
workdir_dir="$plop_json_dir/$workdir"
32+
workdir_parent_dir=$(dirname "$workdir_dir")
33+
relative_wordir_pwd=$(realpath --relative-to="$workdir_parent_dir" "$PWD")
34+
module_path=$(echo "$relative_wordir_pwd" | grep -oE '(/?modules/)[^/]+')
35+
module_name=$(basename "$module_path")
3236

3337
# Check for package.json and plopfile in src directory
3438
if [ ! -f "$src_dir/package.json" ] || { [ ! -f "$src_dir/plopfile.js" ] && [ ! -f "$src_dir/plopfile.ts" ]; }; then
@@ -38,10 +42,12 @@ fi
3842

3943
echo "Found plopfile: [$src_dir/plopfile.*]"
4044
echo "Run plop with codebase: [$workdir_dir]"
45+
echo "Module name: [$module_name]"
4146

4247
# Run Docker with the updated mounts and env variable
4348
docker run -it --rm \
4449
-v "$src_dir:/plop" \
4550
-v "$workdir_dir:/codebase" \
4651
-e CODEBASE_DIR="$workdir_dir" \
52+
-e CODEBASE_MODULE="$module_name" \
4753
ghcr.io/justcoded/plopjs:0.1.0

0 commit comments

Comments
 (0)