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

Use std streams instead of Tempfile? #43

Open
YurySolovyov opened this issue Jun 29, 2017 · 4 comments
Open

Use std streams instead of Tempfile? #43

YurySolovyov opened this issue Jun 29, 2017 · 4 comments

Comments

@YurySolovyov
Copy link
Collaborator

Basically it should be possible to just write something into stdin via echo:

> f = `echo "const foo = () => { return 4 };" | java -jar lib/closure-compiler-20170521.jar`
...
> f
 => "var foo=function(){return 4};\n"
@knowtheory
Copy link
Member

Yeah, this seems like a reasonable way to go. Being able to pipe the output somewhere for inspection might be handy, but the test suite should also raise all of that in a reasonable fashion anyway.

@YurySolovyov
Copy link
Collaborator Author

I was thinking about this more in terms of perf. gains, not a user-facing feature.

@YurySolovyov
Copy link
Collaborator Author

I've been playing with it a bit, it is possible to do that even without echo:

require 'open3'

command = "java -jar lib/closure-compiler-20170626.jar"
stdin, stdout, stderr, wait_thr = Open3::popen3(command)
stdin.write("const foo = () => { return { foo: 321, bar: ['a', 'b', 'c'] } };")
stdin.close
stdout.read

gives me

=> "var foo=function(){return{foo:321,bar:[\"a\",\"b\",\"c\"]}};\n" 

@YurySolovyov
Copy link
Collaborator Author

also, it seems like -XX:TieredStopAtLevel=1 CLI flag reduces startup time significantly

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

No branches or pull requests

2 participants