mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 17:18:32 +02:00
Clean plugin build output directory before bundling
This commit is contained in:
@@ -218,6 +218,7 @@ struct PublishResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn build_plugin_bundle(plugin_dir: &Path) -> CommandResult<Vec<String>> {
|
async fn build_plugin_bundle(plugin_dir: &Path) -> CommandResult<Vec<String>> {
|
||||||
|
prepare_build_output_dir(plugin_dir)?;
|
||||||
let mut bundler = Bundler::new(bundler_options(plugin_dir, false))
|
let mut bundler = Bundler::new(bundler_options(plugin_dir, false))
|
||||||
.map_err(|err| format!("Failed to initialize Rolldown: {err}"))?;
|
.map_err(|err| format!("Failed to initialize Rolldown: {err}"))?;
|
||||||
let output = bundler.write().await.map_err(|err| format!("Plugin build failed:\n{err}"))?;
|
let output = bundler.write().await.map_err(|err| format!("Plugin build failed:\n{err}"))?;
|
||||||
@@ -225,6 +226,16 @@ async fn build_plugin_bundle(plugin_dir: &Path) -> CommandResult<Vec<String>> {
|
|||||||
Ok(output.warnings.into_iter().map(|w| w.to_string()).collect())
|
Ok(output.warnings.into_iter().map(|w| w.to_string()).collect())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn prepare_build_output_dir(plugin_dir: &Path) -> CommandResult {
|
||||||
|
let build_dir = plugin_dir.join("build");
|
||||||
|
if build_dir.exists() {
|
||||||
|
fs::remove_dir_all(&build_dir)
|
||||||
|
.map_err(|e| format!("Failed to clean build directory {}: {e}", build_dir.display()))?;
|
||||||
|
}
|
||||||
|
fs::create_dir_all(&build_dir)
|
||||||
|
.map_err(|e| format!("Failed to create build directory {}: {e}", build_dir.display()))
|
||||||
|
}
|
||||||
|
|
||||||
fn bundler_options(plugin_dir: &Path, watch: bool) -> BundlerOptions {
|
fn bundler_options(plugin_dir: &Path, watch: bool) -> BundlerOptions {
|
||||||
BundlerOptions {
|
BundlerOptions {
|
||||||
input: Some(vec![InputItem { import: "./src/index.ts".to_string(), ..Default::default() }]),
|
input: Some(vec![InputItem { import: "./src/index.ts".to_string(), ..Default::default() }]),
|
||||||
|
|||||||
Reference in New Issue
Block a user