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

This is mandated by the Rust doc of the BufWriter. We've also seen bugs where
the data doesn't seem to be flushed properly, and thus the CLI fails to parse
JSONs emitted by napi-derive. This might be it, or not, but flushing shouldn't
hurt.
This commit is contained in:
Louis 2024-07-23 15:08:13 +02:00 committed by GitHub
parent 0adb1a4992
commit f88b90f71e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,7 +149,8 @@ fn output_type_def(napi: &Napi) {
.and_then(|file| {
let mut writer = BufWriter::<fs::File>::new(file);
writer.write_all(type_def.to_string().as_bytes())?;
writer.write_all("\n".as_bytes())
writer.write_all("\n".as_bytes())?;
writer.flush()
})
.unwrap_or_else(|e| {
println!("Failed to write type def file: {:?}", e);