Skip to content

Commit 0fce860

Browse files
committed
generate: add --clean to delete moved or removed files
1 parent 143fd47 commit 0fce860

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
- name: xtask build
5454
run: cd xtask && cargo build
5555
- name: xtask generate
56-
run: cargo xtask generate ${{ matrix.integration }}
56+
run: cargo xtask generate ${{ matrix.integration }} --clean
5757
- name: check generated files are up-to-date
5858
run: |
5959
git add .

xtask/src/generate.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ pub struct Generate {
6969
/// Directory where to place the generated templates.
7070
#[clap(long)]
7171
out: Option<PathBuf>,
72+
/// Clean generate, deletes the generated directory before generating templates. Use this when you moved or removed
73+
/// files.
74+
#[clap(long)]
75+
clean: bool,
7276
/// A command that should be executed on each generated template.
7377
///
7478
/// If a command fails, this process will fail as well, allowing you to test the template output.
@@ -126,6 +130,10 @@ impl Generate {
126130
.out
127131
.clone()
128132
.unwrap_or_else(|| PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../generated"));
133+
debug!("out_base_dir: {}", out.display());
134+
if self.clean {
135+
std::fs::remove_dir_all(&out)?;
136+
}
129137
std::fs::create_dir_all(&out)?;
130138
Ok(out)
131139
}

0 commit comments

Comments
 (0)