Allow mix projects to specify module.

pull/10/head
Joshua Potter 2023-11-30 07:13:53 -07:00
parent 1b4efbce4b
commit e987caf64b
4 changed files with 38 additions and 2 deletions

View File

@ -35,6 +35,18 @@ function cleanup {
trap cleanup EXIT
# ============================================================
# ENVIRONMENT
# ============================================================
# Trims away any whitespace around the module name.
MODULE=$(echo "$MODULE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [ -z "$MODULE" ]; then
MODULE_ARG=
else
MODULE_ARG="--module '$MODULE'"
fi
# ============================================================
# BUILD
# ============================================================
@ -48,7 +60,9 @@ find "$BUILD" -type d -execdir chmod 755 {} +
# Generate a new project with the specified name using `mix`. Generate in a
# subdirectory to avoid interactive conflict resolution.
nix develop "$BUILD" --command bash -c "mix new $BUILD/project --app '$APP'"
nix develop "$BUILD" \
--command bash \
-c "mix new $BUILD/project --app '$APP' $MODULE_ARG"
# Copy the generated files into the intermediate build directory.
mv -f "$BUILD"/project/* "$BUILD"

View File

@ -2,5 +2,9 @@
"app": {
"type": "line",
"prompt": "App Name> "
},
"module": {
"type": "line",
"prompt": "Module (optional)> "
}
}

View File

@ -35,6 +35,18 @@ function cleanup {
trap cleanup EXIT
# ============================================================
# ENVIRONMENT
# ============================================================
# Trims away any whitespace around the module name.
MODULE=$(echo "$MODULE" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
if [ -z "$MODULE" ]; then
MODULE_ARG=
else
MODULE_ARG="--module '$MODULE'"
fi
# ============================================================
# BUILD
# ============================================================
@ -48,7 +60,9 @@ find "$BUILD" -type d -execdir chmod 755 {} +
# Generate a new project with the specified name using `mix`. Generate in a
# subdirectory to avoid interactive conflict resolution.
nix develop "$BUILD" --command bash -c "mix phx.new $BUILD/project --app '$APP'"
nix develop "$BUILD" \
--command bash \
-c "mix phx.new $BUILD/project --app '$APP' $MODULE_ARG"
# Copy the generated files into the intermediate build directory.
mv -f "$BUILD"/project/* "$BUILD"

View File

@ -2,5 +2,9 @@
"app": {
"type": "line",
"prompt": "App Name> "
},
"module": {
"type": "line",
"prompt": "Module (optional)> "
}
}