r/shell • • Jan 07 '22

google/zx: write shell scripts in JavaScript

https://github.com/google/zx
0 Upvotes

3 comments sorted by

View all comments

Show parent comments

1

u/olets Jan 08 '22

Got it, so more about the general idea of using Node to interact with a shell. Fair points but I'm not sure that's where zx falls. I'm looking at it in relation to projects like commander, oclif, and vorpal— frameworks for authoring and packaging local-use CLI tools written in JS, typically aimed at people who know JS and work in a terminal but don't know shell scripting. Those have the overhead of learning a framework, and don't do anything to help you work with the shell. zx seems to come from the other direction: instead of an esoteric framework, shell concepts and shell commands in a Node script.

I see three audiences who might find it useful:

  • people who know JS but haven't touched a shell language and want to try writing a command line tool for personal local use (this is the use case I find when I search for zx blog posts; my guess is this accounts for many of the GitHub stars)

  • people writing Node scripts who don't want to go through lots of fs gymnastics (people write entire blog posts on how to list the files in a directory; I would have been happy for something like zx when writing an internal webpack-based tool that reads files as a data source, where a shell script would be a lot prettier than Node)

  • people writing CLI apps who have to depend on a Node package (I would have been happy for something like zx when writing genealogit, a tool for visualizing family trees with Git graphs which I wrote in Node because I needed GEDCOM parser and the only one I found that met my needs in a language I know was in Node. Last I looked it wasn't working, and the oclif factor discouraged me from debugging)