Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A README from a parent directory isn't added to the pkg #718

Open
Michael-F-Bryan opened this issue Sep 26, 2019 · 0 comments
Open

A README from a parent directory isn't added to the pkg #718

Michael-F-Bryan opened this issue Sep 26, 2019 · 0 comments

Comments

@Michael-F-Bryan
Copy link

Michael-F-Bryan commented Sep 26, 2019

🐛 Bug description

When using workspaces it's common to have a directory hierarchy like this:

  • /
    • Cargo.toml
    • README.md
    • my-wasm-code/
      • Cargo.toml
      • src/
      • pkg/
    • ...

And the my-wasm-code crate will use the package.readme field in Cargo.toml to tell cargo where to find the README.

[package]
name = "aimc_sim"
version = "0.1.0"
authors = ["Michael Bryan <michaelfbryan@gmail.com>"]
edition = "2018"
description = "WASM frontend for the Adventures in Motion Control simulator"
license = "MIT or Apache-2.0"
repository = "https://github.com/Michael-F-Bryan/adventures-in-motion-control"
publish = false
readme = "../README.md"

At the moment wasm-pack doesn't follow this convention, and will just look in the crate's directory for a README file.

🤔 Expected Behavior

wasm-pack should check the Cargo.toml for a readme field, before falling back to crate_dir.join("README.md") when adding a README.md to the pkg/ directory.

I'm guessing this is the relevant area of code? The naive solution (parse Cargo.toml and try to use the filename from package.readme, if provided) would probably be good enough, but I'm not sure whether this sort of work should be handled elsewhere in the application.

👟 Steps to reproduce

$ mkdir /tmp/repro && cd /tmp/repro

$ cat Cargo.toml
[workspace]
members = ["my-wasm-code"]

$ cat README.md 
# Minimal Repro

$ cargo generate --git https://github.com/rustwasm/wasm-pack-template --name my-wasm-code
 Creating project called `my-wasm-code`...
 Done! New project created /tmp/repro/my-wasm-code

$ ls my-wasm-code
Cargo.toml   src  tests

$ head my-wasm-code/Cargo.toml 
[package]
name = "my-wasm-code"
version = "0.1.0"
authors = ["Michael Bryan <michaelfbryan@gmail.com>"]
edition = "2018"
readme = "../README.md"

$ wasm-pack build my-wasm-code 
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
...
[INFO]: :-) Done in 2m 41s
[INFO]: :-) Your wasm pkg is ready to publish at my-wasm-code/pkg.

$ ls pkg 
my_wasm_code.d.ts  my_wasm_code.js  my_wasm_code_bg.d.ts  my_wasm_code_bg.wasm  package.json

🌍 Your environment

$ wasm-pack --version
wasm-pack 0.8.1
$ rustc --version
rustc 1.39.0-nightly (6ef275e6c 2019-09-24)
@Michael-F-Bryan Michael-F-Bryan changed the title A README from a parent directory isn't added to the pkg/ A README from a parent directory isn't added to the pkg Sep 26, 2019
mre added a commit to tinysearch/tinysearch that referenced this issue May 28, 2020
Note that this will only work as soon as
rustwasm/wasm-pack#718
is fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants