Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
ShellJS: A port of Unix shell commands to Node.js (github.com/arturadib)
38 points by arturadib on March 7, 2012 | hide | past | favorite | 13 comments


OP here.

At Mozilla's PDF.js project we have a large Makefile responsible for everything from custom-bundling our .js files to building our Firefox addon extension and firing up a localhost server.

ShellJS is part of our effort to minimize our dependencies, particularly on Unix commands so as to offer homogenous support to our Windows users. It should also be of use to folks who want to do traditional shell scripting on multiple platforms using JavaScript and a familiar syntax - no need to learn another library. All commands are synchronous, including exec().

We're looking for early adopters and contributors who can help us mature the code. Thanks!


Why did you decide to go with this instead of a cross platform scripting language like Python, Ruby, or Perl? In both cases you need a custom runtime compiled from C or C++ code.


PDF.js is a JavaScript project - that's the language we know for sure all our contributors speak :)


JavaScript is also a cross-platform scripting language.

Coincidentally, it's nice to see JavaScript being used for a much larger variety of tasks. I think it's a very underrated language.


Node.js is just as cross-platform as any of those.


I don't see any callbacks here, which is nice, but doesn't really fit the Node execution model. Do the commands block? Are they queued and executed asynchronously?


I agree that async APIs are almost mandatory in the context of servers (since you don't want to block them while you run I/O commands).

But for shell scripts, not so much. In fact, async would just introduce unnecessary complexity, in particular a nested callback hell as most shell scripts are basically sequences of I/O commands (promises, etc would mitigate the problem somewhat, but again at the expense of another layer of complexity).

That being said... if there's enough demand to use these commands within web servers, adding callback support should be easy. Contributions are welcome! :)


The documentation explicitly says that every call is blocking unless stated otherwise.


I see that now, thanks. I did a quick scan of the doc and didn't see it as it's a little buried.


Very nice, this reminds me of a similar python project.

https://github.com/amoffat/pbs


Yep, similar in spirit but PBS is a wrapper around existing shell commands, whereas ShellJS implements those commands on top of the Node API (which makes the commands portable/cross-platform).


;_;


procstreams is also pretty cool

https://github.com/polotek/procstreams




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: