Skip to content

Commit

Permalink
Ensure destination folder exists before invoking cargo generate (#25)
Browse files Browse the repository at this point in the history
Starting from cargo-generate 0.22.1, the command requires that
destination folder already exists. An error would be thrown otherwise.
This commit changes the code so destination folder would be created
automatically
  • Loading branch information
xxuejie authored Dec 30, 2024
1 parent 8633c0a commit bda9341
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions workspace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ DESTINATION := contracts
generate:
@set -eu; \
if [ "x$(CRATE)" = "x" ]; then \
mkdir -p $(DESTINATION); \
cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \
--destination $(DESTINATION); \
GENERATED_DIR=$$(ls -dt $(DESTINATION)/* | head -n 1); \
Expand All @@ -112,6 +113,7 @@ generate:
sed "s,@@INSERTION_POINT@@,@@INSERTION_POINT@@\n \"$$GENERATED_DIR\"\,," Cargo.toml > Cargo.toml.new; \
mv Cargo.toml.new Cargo.toml; \
else \
mkdir -p $(DESTINATION); \
cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) $(TEMPLATE) \
--destination $(DESTINATION) \
--name $(CRATE); \
Expand All @@ -125,6 +127,7 @@ generate:

generate-native-simulator:
@set -eu; \
mkdir -p native-simulators; \
cargo generate $(TEMPLATE_TYPE) $(TEMPLATE_REPO) native-simulator \
-n $(CRATE)-sim \
--destination native-simulators; \
Expand Down

0 comments on commit bda9341

Please sign in to comment.