This commit replaces the `slog` family of crates used by `wasm-pack`
with the `log` crate plus `env_logger`. This also means that by default
`wasm-pack` also won't create a `wasm-pack.log` file in the current
directory. Enabling logging will now be done through
`RUST_LOG=wasm_pack` instead of `-v` flags.
Closes#425
Issue #277 - Affects running login, pack, and publish on Windows.
`Command::new("npm")` launched `npm` with quotes, `"npm"`, causing a
run-time error on Windows. Now, `Command::new` is wrapped by
`child::new_command(program: &str)`. This prepends `cmd /c` to the
program name if `cfg!(windows)`.
See rustc: #42436, #42791, #44542
`child::run` overrides the stdout config, so is misleading to to set it
differently beforehand. `child::run` uses `spawn()`, which inherits
stdin by default. So, no need to set stdin to default beforehand,
particularly when the spawned program is non-interactive.
All arguments were passed to `arg` inside one string when building a
`Command`. However, using the `arg` function, "only one argument can be
passed per use." This caused all arguments accidentally to be appended
to the registry URL. For example: After a successful login with a
provided `--auth_type`, the success message incorrectly displayed:
"Logged in as asf on https://registry.npmjs.org/%20--auth_type=Basic."
The space (%20 in hex) was caused by adding a fixed space before each
additional argument.
This commit pushes all arguments onto a `Vec<String>`. Then, the `args`
function adds the arguments separately to the command. This removes the
need to prepend spaces to each argument. Alternatively, `arg` could have
been used throughout to build the command argument-by-argument. However,
using `args` partitions the code more neatly into two distinct sections.
Issue #484.
PR392 inadvertantly replaced the `login` interactive process spawner
with
`child::run`, which is hard-coded to buffer stdout/stderr. This caused
`login` to become essentially unusable; the user could no longer see
interactive input prompts or error messages displayed by `npm adduser`.
The code was not directly reverted because the previous version:
1. Returned Error instead of failure::Error. (Updated to use
`bail!`, which is consistent with `publish`.)
2. Displayed all stderr only upon exit, rather than interactively
displaying it. This led to repeated interactive prompts without
informing the user why. (Updated to use `status()` which inherits
stdin/stdout/stderr by default.)
3. Did not provide logging. (Now duplicates the logging in
`child::run`.)