Skip to content

CLI support for piping#380

Merged
devongovett merged 2 commits intoparcel-bundler:masterfrom
oylenshpeegul:support-for-piping
Jan 3, 2023
Merged

CLI support for piping#380
devongovett merged 2 commits intoparcel-bundler:masterfrom
oylenshpeegul:support-for-piping

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
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