mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 17:25:15 +02:00
Add wasm sample for CI (#2372)
* Add wasm sample for CI * Add wasm sample for CI * Add wasm sample for CI
This commit is contained in:
@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::io::Read;
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct HtmlThemes {
|
||||
@ -183,6 +182,7 @@ fn get_theme_from_asset_file(
|
||||
Ok(convert_html_theme_to_hash_map(is_dark, th))
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn get_asset_by_name_as_html_themes(
|
||||
zip_name: &str,
|
||||
json_name: &str,
|
||||
@ -194,11 +194,20 @@ fn get_asset_by_name_as_html_themes(
|
||||
Cow::Owned(bytes) => bytes,
|
||||
};
|
||||
let reader = std::io::Cursor::new(asset);
|
||||
let mut archive = zip::ZipArchive::new(reader)?;
|
||||
let mut zip_file = archive.by_name(json_name)?;
|
||||
let mut contents = String::new();
|
||||
zip_file.read_to_string(&mut contents)?;
|
||||
Ok(serde_json::from_str(&contents)?)
|
||||
#[cfg(feature = "zip")]
|
||||
{
|
||||
use std::io::Read;
|
||||
let mut archive = zip::ZipArchive::new(reader)?;
|
||||
let mut zip_file = archive.by_name(json_name)?;
|
||||
let mut contents = String::new();
|
||||
zip_file.read_to_string(&mut contents)?;
|
||||
Ok(serde_json::from_str(&contents)?)
|
||||
}
|
||||
#[cfg(not(feature = "zip"))]
|
||||
{
|
||||
let th = HtmlThemes::default();
|
||||
Ok(th)
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let th = HtmlThemes::default();
|
||||
|
4
crates/nu-cli/src/env/host.rs
vendored
4
crates/nu-cli/src/env/host.rs
vendored
@ -76,6 +76,7 @@ impl Host for BasicHost {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn vars(&mut self) -> Vec<(String, String)> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
@ -88,6 +89,7 @@ impl Host for BasicHost {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn env_get(&mut self, key: OsString) -> Option<OsString> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
@ -99,6 +101,7 @@ impl Host for BasicHost {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn env_set(&mut self, key: OsString, value: OsString) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
@ -106,6 +109,7 @@ impl Host for BasicHost {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn env_rm(&mut self, key: OsString) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ fn is_executable(file: &DirEntry) -> bool {
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn is_executable(file: &DirEntry) -> bool {
|
||||
fn is_executable(_file: &DirEntry) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user