Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions yarn-project/aztec/scripts/add_crate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ TEMPLATE_DIR="$(dirname $0)/templates/$template"
# Copy template crates and substitute placeholders
cp -r "$TEMPLATE_DIR/contract" "$contract_dir"
cp -r "$TEMPLATE_DIR/test" "$test_dir"
# Use perl -i for portability across os.
find "$contract_dir" "$test_dir" -type f -exec \
sed -i -e "s/__CRATE_NAME__/${crate_name}/g" -e "s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +
perl -i -pe "s/__CRATE_NAME__/${crate_name}/g; s/__AZTEC_VERSION__/${AZTEC_VERSION}/g" {} +

# Add members to workspace Nargo.toml
if grep -q 'members\s*=\s*\[\s*\]' Nargo.toml; then
# Empty array: members = []
sed -i "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
perl -i -pe "s|members\s*=\s*\[\s*\]|members = [\"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
else
# Non-empty array: add before closing ]
sed -i "s|\(members\s*=\s*\[.*\)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
perl -i -pe "s|(members\s*=\s*\[.*)\]|\1, \"${contract_dir}\", \"${test_dir}\"]|" Nargo.toml
fi

echo "Created crates '${contract_dir}' and '${test_dir}'"
Loading