mirror of
https://github.com/swc-project/swc.git
synced 2024-11-28 11:13:43 +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::{
|
use std::{
|
||||||
fs::{self, File},
|
fs::{self, File},
|
||||||
io::{self, BufRead, Write},
|
io::{self, Read, Write},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
@ -245,14 +245,14 @@ fn collect_stdin_input() -> Option<String> {
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(
|
let mut buffer = String::new();
|
||||||
io::stdin()
|
let result = io::stdin().lock().read_to_string(&mut buffer);
|
||||||
.lock()
|
|
||||||
.lines()
|
if result.is_ok() && !buffer.is_empty() {
|
||||||
.map(|line| line.expect("Not able to read stdin"))
|
Some(buffer)
|
||||||
.collect::<Vec<String>>()
|
} else {
|
||||||
.join("\n"),
|
None
|
||||||
)
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InputContext {
|
struct InputContext {
|
||||||
|
Loading…
Reference in New Issue
Block a user