Skip to content

Commit

Permalink
feat: add --out-dir cli flag
Browse files Browse the repository at this point in the history
  • Loading branch information
amr-crabnebula committed Sep 21, 2023
1 parent 3a4bb35 commit ffad113
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 37 deletions.
66 changes: 32 additions & 34 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
},
"outDir": {
"description": "the directory where the `binaries` exist and where the packages will be placed.",
"description": "The directory where the `binaries` exist and where the packages will be placed.",
"default": "",
"type": "string"
},
Expand Down
2 changes: 1 addition & 1 deletion crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ pub struct Config {
///
/// if not present, we'll use the PackageType list for the target OS.
pub formats: Option<Vec<PackageFormat>>,
/// the directory where the `binaries` exist and where the packages will be placed.
/// The directory where the `binaries` exist and where the packages will be placed.
#[serde(default, alias = "out-dir", alias = "out_dir")]
pub out_dir: PathBuf,
/// The target triple. Defaults to the current OS target triple.
Expand Down
2 changes: 1 addition & 1 deletion crates/packager/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
},
"outDir": {
"description": "the directory where the `binaries` exist and where the packages will be placed.",
"description": "The directory where the `binaries` exist and where the packages will be placed.",
"default": "",
"type": "string"
},
Expand Down
8 changes: 8 additions & 0 deletions crates/packager/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ pub(crate) struct Cli {
/// Specify which packages to use from the current workspace.
#[clap(short, long, value_delimiter = ',')]
packages: Option<Vec<String>>,
/// Specify The directory where the `binaries` exist and where the packages will be placed.
out_dir: Option<PathBuf>,

/// Package the release version of your app.
/// Ignored when `--config` is used.
Expand Down Expand Up @@ -125,7 +127,13 @@ fn run(cli: Cli) -> Result<()> {
log::warn!("Couldn't detect a valid configuration file! Nothing to do here.")
}

let cli_out_dir = cli.out_dir.as_ref().map(dunce::canonicalize).transpose()?;

for (_, config) in &mut configs {
if let Some(dir) = &cli_out_dir {
config.out_dir = dir.clone()
}

if let Some(formats) = &cli.formats {
config.formats.replace(formats.clone());
}
Expand Down

0 comments on commit ffad113

Please sign in to comment.