Skip to content

Commit

Permalink
Merge pull request #144 from baoyachi/wasm_example
Browse files Browse the repository at this point in the history
add wasm example
  • Loading branch information
baoyachi authored Dec 8, 2023
2 parents 1a36c64 + 24d3bd8 commit 96fdafc
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ jobs:
cargo run
working-directory: ./example_shadow_hook

# example_wasm check
- uses: jetli/[email protected]
with:
version: latest
- name: Setup wasm-pack
run: |
cargo b
wasm-pack build --target bundler
wasm-pack build --target web
working-directory: ./example_wasm

# build on nightly
- uses: actions-rs/toolchain@v1
with:
Expand Down
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ license = "MIT AND Apache-2.0"
exclude = ["shadow-rs.png", "build_module.png"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[package.metadata.docs.rs]
all-features = true

Expand All @@ -40,4 +39,4 @@ default = ["git2", "tzdb"]
regex = "1.7.0"

[workspace]
members = ["example_shadow", "example_shadow_hook"]
members = ["example_shadow", "example_shadow_hook", "example_wasm"]
13 changes: 13 additions & 0 deletions example_wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "example_wasm"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]


[dependencies]
shadow-rs = { path = "../", default-features = false, features = ["tzdb"] }
1 change: 1 addition & 0 deletions example_wasm/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

5 changes: 3 additions & 2 deletions src/git.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::build::{ConstType, ConstVal, ShadowConst};
use crate::ci::CiType;
use crate::date_time::DateTime;
use crate::err::*;
use crate::Format;
use std::collections::BTreeMap;
use std::io::{BufReader, Read};
use std::path::Path;
Expand Down Expand Up @@ -135,10 +133,13 @@ impl Git {
Ok(())
}

#[allow(unused_variables)]
fn init_git2(&mut self, path: &Path) -> SdResult<()> {
#[cfg(feature = "git2")]
{
use crate::date_time::DateTime;
use crate::git::git2_mod::git_repo;
use crate::Format;

let repo = git_repo(path).map_err(ShadowError::new)?;
let reference = repo.head().map_err(ShadowError::new)?;
Expand Down

0 comments on commit 96fdafc

Please sign in to comment.