Skip to content

Commit

Permalink
xtask: add --pre-release flag to the package task
Browse files Browse the repository at this point in the history
  • Loading branch information
SpontanCombust committed May 8, 2024
1 parent e6b1d23 commit 0adcb03
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/dev-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ Currently available xtask commands:
- `package` - build and package VSCode extension into a .vsix file
- `--out` - output path for the .vsix file; default is "./witcherscript-ide.vsix"
- `--target` - VSCode extension target, e.g. win32-x64
- `install` - build, package and install the VSCode extension
- `--pre-release` - mark the package as pre-release
- `install` - build, package and install the VSCode extension locally


## Debugging
Expand Down
5 changes: 4 additions & 1 deletion xtask/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ pub enum Commands {
///
/// https://code.visualstudio.com/api/working-with-extensions/publishing-extension#platformspecific-extensions
#[arg(long)]
target: Option<String>
target: Option<String>,
/// Mark the packed extension as pre-release
#[arg(long)]
pre_release: bool
},
/// Build, package and install the VSCode extension
Install
Expand Down
5 changes: 4 additions & 1 deletion xtask/src/commands/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const VSIX_NAME: &'static str = "witcherscript-ide.vsix";
const NPM: &'static str = if cfg!(windows) { "npm.cmd" } else { "npm" };
const NPX: &'static str = if cfg!(windows) { "npx.cmd" } else { "npx" };

pub fn package(output: Option<String>, code_target: Option<String>) -> anyhow::Result<()> {
pub fn package(output: Option<String>, code_target: Option<String>, pre_release: bool) -> anyhow::Result<()> {
let sh = Shell::new()?;
let root = project_root::get_project_root()?;
let cwd = std::env::current_dir()?;
Expand All @@ -26,6 +26,9 @@ pub fn package(output: Option<String>, code_target: Option<String>) -> anyhow::R
if let Some(code_target) = &code_target {
package_opt_args.extend(["--target", code_target])
}
if pre_release {
package_opt_args.extend(["--pre-release"]);
}

cmd!(sh, "{NPM} --version").run().with_context(|| "npm is required")?;
cmd!(sh, "{NPM} ci").run()?;
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn main() -> anyhow::Result<()> {
match cli.command {
cli::Commands::PrepServer { release, target } => commands::prep_server(release, target),
cli::Commands::PrepClient { watch, fast } => commands::prep_client(watch, fast),
cli::Commands::Package { out, target } => commands::package(out, target),
cli::Commands::Package { out, target, pre_release } => commands::package(out, target, pre_release),
cli::Commands::Install => commands::install()
}
}

0 comments on commit 0adcb03

Please sign in to comment.