Skip to content

Commit 2d2cb24

Browse files
committed
expose postinstall
1 parent 3e2b5e5 commit 2d2cb24

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

src/args.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ pub struct Cli {
1616

1717
#[derive(Subcommand)]
1818
pub enum Commands {
19+
#[clap(hide = true)]
20+
Postinstall,
21+
1922
/// Build the project and install it locally (into VFS).
2023
Build(BuildArgs),
2124

src/cli.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use std::path::PathBuf;
66
pub fn run_command(vfs: PathBuf, command: &Commands) -> anyhow::Result<()> {
77
use Commands::*;
88
match command {
9+
Postinstall => cmd_postinstall(),
910
Build(args) => cmd_build(vfs, args),
1011
Export(args) => cmd_export(&vfs, args),
1112
Import(args) => cmd_import(&vfs, args),

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub use logs::cmd_logs;
3131
pub use monitor::cmd_monitor;
3232
pub use name::{cmd_name_generate, cmd_name_get, cmd_name_set};
3333
pub use new::cmd_new;
34+
pub use postinstall::cmd_postinstall;
3435
pub use repl::cmd_repl;
3536
pub use runtime::{cmd_exit, cmd_id, cmd_launch, cmd_restart, cmd_screenshot};
3637
pub use shots::cmd_shots_download;

src/commands/postinstall.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{Result, bail};
1+
use anyhow::{Context, Result, bail};
22
use std::{
33
io::Write,
44
path::{Path, PathBuf},
@@ -33,8 +33,11 @@ fn move_self_to(new_path: &Path) -> Result<()> {
3333
bail!("cannot access process args");
3434
};
3535
let old_path = PathBuf::from(old_path);
36+
if !old_path.exists() {
37+
bail!("the binary is execute not by its path");
38+
}
3639
let new_path = new_path.join("firefly_cli");
37-
std::fs::rename(old_path, new_path)?;
40+
std::fs::rename(old_path, new_path).context("move binary")?;
3841
Ok(())
3942
}
4043

0 commit comments

Comments
 (0)