fix(napi-derive): call flush on the BufWriter (#2242)

This commit is contained in:
Richer 2024-09-02 14:16:00 +08:00 committed by GitHub
parent 21f712aa50
commit 58bcb64c19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -130,7 +130,8 @@ fn output_wasi_register_def(napi: &Napi) {
let mut writer = BufWriter::<fs::File>::new(file);
let pkg_name: String = std::env::var("CARGO_PKG_NAME").expect("CARGO_PKG_NAME is not set");
writer.write_all(format!("{pkg_name}: {}", napi.register_name()).as_bytes())?;
writer.write_all("\n".as_bytes())
writer.write_all("\n".as_bytes())?;
writer.flush()
})
.unwrap_or_else(|e| {
println!("Failed to write wasi register file: {:?}", e);