|
|
|
@ -19,11 +19,11 @@ |
|
|
|
|
use std::env; |
|
|
|
|
use std::fs; |
|
|
|
|
use std::io; |
|
|
|
|
use std::io::IsTerminal; |
|
|
|
|
use std::path::Path; |
|
|
|
|
use std::process; |
|
|
|
|
|
|
|
|
|
use anyhow::{anyhow, bail, Context, Result}; |
|
|
|
|
use atty; |
|
|
|
|
use which; |
|
|
|
|
|
|
|
|
|
pub fn install() -> ! { |
|
|
|
@ -91,9 +91,11 @@ fn confirm_can_overwrite(dst: &Path) -> Result<()> { |
|
|
|
|
return Ok(()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
let stdin = io::stdin(); |
|
|
|
|
|
|
|
|
|
// If we're not attached to a TTY then we can't get user input, so there's
|
|
|
|
|
// nothing to do except inform the user about the `-f` flag.
|
|
|
|
|
if !atty::is(atty::Stream::Stdin) { |
|
|
|
|
if !stdin.is_terminal() { |
|
|
|
|
bail!( |
|
|
|
|
"existing wasm-pack installation found at `{}`, pass `-f` to \ |
|
|
|
|
force installation over this file, otherwise aborting \ |
|
|
|
@ -110,9 +112,7 @@ fn confirm_can_overwrite(dst: &Path) -> Result<()> { |
|
|
|
|
); |
|
|
|
|
eprint!("info: would you like to overwrite this file? [y/N]: "); |
|
|
|
|
let mut line = String::new(); |
|
|
|
|
io::stdin() |
|
|
|
|
.read_line(&mut line) |
|
|
|
|
.context("failed to read stdin")?; |
|
|
|
|
stdin.read_line(&mut line).context("failed to read stdin")?; |
|
|
|
|
|
|
|
|
|
if line.starts_with('y') || line.starts_with('Y') { |
|
|
|
|
return Ok(()); |
|
|
|
|