fix scripts
This commit is contained in:
@@ -1,13 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
name="$1"
|
||||
|
||||
if [ -z "$name" ]; then
|
||||
echo "Usage: ./monorepo-cargo-new.sh <project_name>"
|
||||
echo "❌ Usage: ./monorepo-cargo-new.sh <project_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Step 1: Create new cargo project without initializing Git
|
||||
cargo new "$name" --vcs none
|
||||
echo " \"$name\"," >> Cargo.toml
|
||||
|
||||
# Step 2: Insert the project into the [workspace] members list in Cargo.toml
|
||||
if grep -q "^\[workspace\]" Cargo.toml; then
|
||||
# Avoid duplicate entries
|
||||
if grep -q "\"$name\"" Cargo.toml; then
|
||||
echo "⚠️ Project '$name' already exists in workspace members. Skipping insertion."
|
||||
else
|
||||
echo "📦 Adding '$name' to workspace members..."
|
||||
|
||||
# Insert before the closing bracket of members array
|
||||
sed -i "/members\s*=\s*\[/,/]/ s/^\(\s*\)\]/ \"$name\",\n\1]/" Cargo.toml
|
||||
fi
|
||||
else
|
||||
echo "❌ No [workspace] section found in Cargo.toml."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "✅ Project '$name' created and added to workspace!"
|
||||
|
||||
|
Reference in New Issue
Block a user