diff --git a/backend/src/s9pk/builder.rs b/backend/src/s9pk/builder.rs index 24e61673b..8478215a7 100644 --- a/backend/src/s9pk/builder.rs +++ b/backend/src/s9pk/builder.rs @@ -29,7 +29,7 @@ pub struct S9pkPacker< icon: RIcon, docker_images: RDockerImages, assets: RAssets, - scripts: RScripts, + scripts: Option, } impl< 'a, @@ -118,14 +118,16 @@ impl< }; position = new_pos; // scripts - std::io::copy(&mut self.scripts, &mut writer) - .with_ctx(|_| (crate::ErrorKind::Filesystem, "Copying Scripts"))?; - let new_pos = writer.inner_mut().stream_position()?; - header.table_of_contents.scripts = Some(FileSection { - position, - length: new_pos - position, - }); - position = new_pos; + if let Some(mut scripts) = self.scripts { + std::io::copy(&mut scripts, &mut writer) + .with_ctx(|_| (crate::ErrorKind::Filesystem, "Copying Scripts"))?; + let new_pos = writer.inner_mut().stream_position()?; + header.table_of_contents.scripts = Some(FileSection { + position, + length: new_pos - position, + }); + position = new_pos; + } // header let (hash, _) = writer.finish(); diff --git a/backend/src/s9pk/mod.rs b/backend/src/s9pk/mod.rs index c611f4faa..57601572e 100644 --- a/backend/src/s9pk/mod.rs +++ b/backend/src/s9pk/mod.rs @@ -107,7 +107,11 @@ pub fn pack(#[context] ctx: SdkContext, #[arg] path: Option) -> Result< }) .scripts({ let script_path = path.join(manifest.assets.scripts_path()).join("embassy.js"); - File::open(script_path)? + if script_path.exists() { + Some(File::open(script_path)?) + } else { + None + } }) .build() .pack(&ctx.developer_key()?)?;