This will fix the broken spinners that indicate steps which are
currently in progress. To achieve this the behavior of the progressbar
helper had to be adjusted.
The multibar does not work while a child process is run with
`std::process::Command`. Using multiple spinners without a multibar is
problematic as well because emitting warnings, infos and errors while a
single spinner is active will duplicate the spinners message. The
spinner will also absorb the last warning/error/info. Instead of
publishing warnings, errors and infos immediately they will now be
cached and only output when the current spinner finishes.
To make sure we can output all warnings to the user ProgressBars are no
longer exposed to the caller. Instead the active spinner will be
finished implicitly when a new spinner is allocated with the `message()`
function. Instead of relying on the `done()` function to be called the
progressbar now implements the `Drop` trait which will finish the last
spinner automatically.
Unfortunately, this introduces members that have to be mutable. To not
have to deal with mutable ProgressOutput all over the place the members
were put inside an RwLock. This allows us to use ProgressOutput from
inside multiple threads to emit warnings and errors.
This commit does a few things:
- Sets up the ability to log information based off log level
- Figures out where to log the file
- Starts logging information in the program
As this is a first pass the logging is good enough to know where things
went wrong, but we can expand on this in the future to log many many
things. We just now have an initial implementation. The log is written
out to a file that can be read by the user if they pass in -v, -vv, etc.
where each v is an extra level of logging.
Remove quicli from the code base. It's a fantastic library to get
started, but in order to implement logging as well as just maintaining
the library in general it was easier to remove it and continue work
without it. While we were going to remove it in 0.4 we found it easier
to remove now to implement logging.
This does two big things:
- We add custom error messages and conversions from other error types
into our own error type. This means we can create or modify more
fine grained errors rather than using whatever `failure::Error` gives
us. The first one we have is a `Cli` error, whereby calls to things
like wasm-bindgen or npm failed.
- We also make it so that `PBAR.error()` is called only on exit. We grab
a reference to whatever error gets passed up the chain, have it
generate a message to be printed as an error to PBAR, close up PBAR
like normal, and then print our actual error message to stderr!
The main benefits of this is that as long as we return an error, PBAR
will print and close itself up and we don't need to call it every time
or forget that we would need to call it, and we put error details
specifically into our error!
Closes#12
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"
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