This commit does quite a few things in order to get this to work:
1. We move all of the code dealing with knowing which command to run
into it's own function. This wrapper command allows us to always
close out PBAR before dumping error output. This fixes a problem
where stderr and stdout were borked and not printing out error
messages correctly.
2. We then refactor the code that has a panic to return early with that
error message.
3. If the command we ran errored, we print out with PBAR that there was
an error with the program we ran (not wasm-pack itself) then dump the
stderr from the command to the actual stderr
This means we can abort early on without continuing any of the other
parts of wasm-pack and let the user know what the error was rather than
just saying "There's an error"
We want to make sure people format their code as well as reference the
issue that's going to be closed as well so we don't have to close the
issue manually! This PR adds a template for PRs that includes these
points as a checklist to ensure future contributors know what they need
to do!
Functions to new module. Tidies up reused code into
private function.
Throws warning due to line 11 in command.rs - unused import
Import is used for the StructOpt derive macro, so is needed
but still throws this warning
This commit allows us to have a global progress bar to write data to
giving us the following benefits:
- Consistent ways to handle types of messages such as errors and
warnings
- Easy interface to add progress bars of various types
- Easy to maintain, add new types of bars, or more while encapsulating
the login in a single module
Because the toml error only spits out the error for the first thing it
runs into it doesn't parse all of the missing fields. We first serialize
the data to a generic toml type to check this ourselves. If everything
is there we serialize directly to the type we expected. Otherwise we
throw an error with all the fields that are missing.
npm allows scopes to avoid name collisions. In order to support this
optional feature a flag has been added so that the name in the generated
package.json is correct.
Example for a package named wasm-add:
```bash
wasm-pack init
```
package.json
```json
{
"name": "wasm-add"
}
```
```bash
wasm-pack init --scope mgattozzi
```
package.json
```json
{
"name": "@mgattozzi/wasm-add"
}
```