mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-14 15:47:12 +00:00
Fix crates export
This commit is contained in:
parent
8b07c6b695
commit
88b9fd197a
2 changed files with 3 additions and 2 deletions
|
@ -155,7 +155,7 @@ impl BooksTask {
|
|||
Ok(result) => {
|
||||
let books: Vec<_> = result.into_iter().filter(|book| !book.is_empty()).collect();
|
||||
let contents = format!(
|
||||
"let N=null;const booksIndex={};export default booksIndex;",
|
||||
"var N=null;const booksIndex={};export default booksIndex;",
|
||||
serde_json::to_string(&books)?
|
||||
);
|
||||
let path = Path::new(&self.dest_path);
|
||||
|
|
|
@ -110,7 +110,7 @@ fn generate_javascript_crates_index(crates: &[Crate], minifier: &Minifier) -> St
|
|||
})
|
||||
.collect();
|
||||
let crate_index = format!(
|
||||
"const crateIndex={};export default crateIndex;",
|
||||
"const crateIndex={};",
|
||||
serde_json::to_string(&crates_map).unwrap()
|
||||
);
|
||||
contents.push_str(&Minifier::minify_js(&crate_index));
|
||||
|
@ -179,6 +179,7 @@ impl Task for CratesTask {
|
|||
serde_json::to_string(&mapping)?
|
||||
);
|
||||
contents.push_str(&generate_javascript_crates_index(&crates, &minifier));
|
||||
contents.push_str("export {mapping,crateIndex};");
|
||||
let path = Path::new(&self.dest_path);
|
||||
fs::write(path, &contents)?;
|
||||
println!("\nGenerate javascript crates index successful!");
|
||||
|
|
Loading…
Reference in a new issue