mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 18:28:13 +03:00
fix(bindings/cli): Skip empty stdin in non tty environments (#6714)
This commit is contained in:
parent
918a01bf5c
commit
0076418819
@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
fs::{self, File},
|
||||
io::{self, BufRead, Write},
|
||||
io::{self, Read, Write},
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
};
|
||||
@ -245,14 +245,14 @@ fn collect_stdin_input() -> Option<String> {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(
|
||||
io::stdin()
|
||||
.lock()
|
||||
.lines()
|
||||
.map(|line| line.expect("Not able to read stdin"))
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n"),
|
||||
)
|
||||
let mut buffer = String::new();
|
||||
let result = io::stdin().lock().read_to_string(&mut buffer);
|
||||
|
||||
if result.is_ok() && !buffer.is_empty() {
|
||||
Some(buffer)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
struct InputContext {
|
||||
|
Loading…
Reference in New Issue
Block a user