mirror of
https://github.com/nushell/nushell.git
synced 2025-08-18 06:10:18 +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:
@@ -90,7 +90,7 @@ umask = "1.0.0"
|
||||
unicode-xid = "0.2.1"
|
||||
uuid_crate = {package = "uuid", version = "0.8.1", features = ["v4"], optional = true}
|
||||
which = {version = "4.0.2", optional = true}
|
||||
zip = "0.5.6"
|
||||
zip = {version = "0.5.6", optional = true}
|
||||
|
||||
clipboard = {version = "0.5", optional = true}
|
||||
encoding_rs = "0.8.23"
|
||||
@@ -115,7 +115,7 @@ optional = true
|
||||
version = "0.23.1"
|
||||
|
||||
[build-dependencies]
|
||||
git2 = "0.13"
|
||||
git2 = {version = "0.13", optional = true}
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
|
@@ -1,4 +1,3 @@
|
||||
use git2::Repository;
|
||||
use std::path::Path;
|
||||
use std::{env, fs, io};
|
||||
|
||||
@@ -18,11 +17,20 @@ fn main() -> Result<(), io::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn latest_commit_hash<P: AsRef<Path>>(dir: P) -> Result<String, git2::Error> {
|
||||
let dir = dir.as_ref();
|
||||
Ok(Repository::discover(dir)?
|
||||
.head()?
|
||||
.peel_to_commit()?
|
||||
.id()
|
||||
.to_string())
|
||||
#[allow(unused_variables)]
|
||||
fn latest_commit_hash<P: AsRef<Path>>(dir: P) -> Result<String, Box<dyn std::error::Error>> {
|
||||
#[cfg(feature = "git2")]
|
||||
{
|
||||
use git2::Repository;
|
||||
let dir = dir.as_ref();
|
||||
Ok(Repository::discover(dir)?
|
||||
.head()?
|
||||
.peel_to_commit()?
|
||||
.id()
|
||||
.to_string())
|
||||
}
|
||||
#[cfg(not(feature = "git2"))]
|
||||
{
|
||||
Ok(String::new())
|
||||
}
|
||||
}
|
||||
|
@@ -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