|
@@ -249,7 +249,7 @@ pub enum Command {
|
|
#[clap(subcommand)]
|
|
#[clap(subcommand)]
|
|
subcmd: IdlCommand,
|
|
subcmd: IdlCommand,
|
|
},
|
|
},
|
|
- /// Remove all artifacts from the target directory except program keypairs.
|
|
|
|
|
|
+ /// Remove all artifacts from the generated directories except program keypairs.
|
|
Clean,
|
|
Clean,
|
|
/// Deploys each program in the workspace.
|
|
/// Deploys each program in the workspace.
|
|
Deploy {
|
|
Deploy {
|
|
@@ -3733,9 +3733,15 @@ fn cluster_url(cfg: &Config, test_validator: &Option<TestValidator>) -> String {
|
|
fn clean(cfg_override: &ConfigOverride) -> Result<()> {
|
|
fn clean(cfg_override: &ConfigOverride) -> Result<()> {
|
|
let cfg = Config::discover(cfg_override)?.expect("Not in workspace.");
|
|
let cfg = Config::discover(cfg_override)?.expect("Not in workspace.");
|
|
let cfg_parent = cfg.path().parent().expect("Invalid Anchor.toml");
|
|
let cfg_parent = cfg.path().parent().expect("Invalid Anchor.toml");
|
|
|
|
+ let dot_anchor_dir = cfg_parent.join(".anchor");
|
|
let target_dir = cfg_parent.join("target");
|
|
let target_dir = cfg_parent.join("target");
|
|
let deploy_dir = target_dir.join("deploy");
|
|
let deploy_dir = target_dir.join("deploy");
|
|
|
|
|
|
|
|
+ if dot_anchor_dir.exists() {
|
|
|
|
+ fs::remove_dir_all(&dot_anchor_dir)
|
|
|
|
+ .map_err(|e| anyhow!("Could not remove directory {:?}: {}", dot_anchor_dir, e))?;
|
|
|
|
+ }
|
|
|
|
+
|
|
if target_dir.exists() {
|
|
if target_dir.exists() {
|
|
for entry in fs::read_dir(target_dir)? {
|
|
for entry in fs::read_dir(target_dir)? {
|
|
let path = entry?.path();
|
|
let path = entry?.path();
|