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

Command line flag to specify output file name #247

Open
Irrelon opened this issue Nov 11, 2014 · 2 comments
Open

Command line flag to specify output file name #247

Irrelon opened this issue Nov 11, 2014 · 2 comments
Labels

Comments

@Irrelon
Copy link

Irrelon commented Nov 11, 2014

Hey,

First off, this is absolutely awesome, seriously great work. JS has sorely needed this sort of thing since forever.

I've created a file watcher in WebStorm to automatically output generated files as their source changes by running the _node -c on the file. I was wondering how complex it would be to allow a further parameter to specify the output file name, or to output the result directly to the calling process (webstorm can take the stdout and save it separately).

Something like this:

_node -c myfilewithanyextension.js -out myfilewithanyextension.sl.js

Or to get the compiled version returned in stdout:

_node -c myfile.js -stdout

I suspect this would be a very easy change and am happy to dive in an do this myself but wanted to know if there are any obvious "gotchas" with what I'm proposing?

THANKS!!!

@bjouhier
Copy link
Member

I have a question: why don't you use the ._js extension? This way the -c option would be sufficient.

Otherwise, this should not be too hard to implement. A few gotchas:

  • There is already a -o option but it is used to specify an output directory. I would not reserve a single letter for the new option because it is a bit special (source file with non-standard extension). I would call it --output-file
  • Implementation should not be too difficult. You would need to add the option in command.js, and then modify compiler._js/outputFile
  • Redirecting the output to stdout is more challenging because the code is designed to write to a file. If you really need it, I suggest to use --output-file -, which is a standard syntax for stdout in the unix world.

@aseemk
Copy link
Contributor

aseemk commented Nov 11, 2014

If reworking the code to stream to stdout is important, this could always be a "second step" in command.js: run the compiler like normal outputting to a temp file, then stream the temp file to stdout, before deleting it. A bit hacky maybe, but should get the job done. =)

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

No branches or pull requests

3 participants