Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI support for piping #380

Merged
merged 2 commits into from
Jan 3, 2023

Conversation

oylenshpeegul
Copy link
Contributor

@oylenshpeegul oylenshpeegul commented Jan 2, 2023

Resolves #375

src/main.rs: made input_file optional and use stdin and a fake name if it's None
Cargo.toml: added new cli dependency on atty for detecting pipe
rust-toolchain.toml: bumped version of Rust for stable std::io::read_to_string
tests/cli_integration_tests.rs: removed test for no_input_file

src/main.rs: made input_file optional and use stdin and a fake name if it's None
Cargo.toml: added new cli dependency on atty for detecting pipe
rust-toolchain.toml: bumped version of Rust for stable std::io::read_to_string
tests/cli_integration_tests.rs: removed test for no_input_file
Cargo.toml Outdated Show resolved Hide resolved
Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@devongovett devongovett merged commit 3a5a30a into parcel-bundler:master Jan 3, 2023
@oylenshpeegul oylenshpeegul deleted the support-for-piping branch January 3, 2023 12:19
@roman01la
Copy link

Is there a test case for stdin input? It doesn't seem to work for me, unless I'm doing something wrong :(

@oylenshpeegul
Copy link
Contributor Author

What did you try? I just built the latest version and this seems to work for me.

❯ git clone https://github.com/parcel-bundler/lightningcss.git
❯ cd lightningcss
❯ cargo build --features=cli --release
...
❯ $CARGO_TARGET_DIR/release/lightningcss -h
...
❯ cat tests/testdata/a.css 
@import "b.css";

.a {
  width: 32px;
}

❯ cat tests/testdata/a.css | $CARGO_TARGET_DIR/release/lightningcss --minify
@import "b.css";.a{width:32px}

If it detects that STDIN has not been redirected, it gives an error rather than silently wait for input.

❯ $CARGO_TARGET_DIR/release/lightningcss 
Error: Custom { kind: Other, error: "Not reading from stdin as it was not redirected" }

@roman01la
Copy link

@oylenshpeegul Ignore my stupidity, sorry :) It works flawlessly!

@oylenshpeegul
Copy link
Contributor Author

No worries! Have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI support for piping
3 participants