I saw that the other day, I must say I like a lot because it looks similar to a thing I did a while ago. But there is a "missed oportunity" in this tool. The implementation of $ is not really cross-platform, which is quite a shame. Also, it would be nice if they provide an argument parser like minimist or arg.
Yeah, I think it's still very new, and might mature in the future. I have high hopes for it.
I don't usually think about shell scripts as accepting arguments, I usually build CLIs for that use case, with things like oclif or js-fire. But when I was trying to use arguments in zx even if for the sake of my example, I did miss a better way to parse arguments than process.argv. Hopefully it's something they'll add in the near future.
Looking throught the issues it does appear like the maintainer wants to keep things as simple as possible. Doesn't look too eager to change things. Anyway, is still a good project.
You know I just remembered something: one can actually install this tool directly from github. So, people could fork this project, tweak a little bit and then install the fork like this.
npm install--global github:<some-user-name>/zx
That would be an interesting use of this npm install feature.
Oh, that's a really good idea. Especially since the work required would be minimal, for example using minimist for arguments would imply adding a few lines for importing the package and exposing it within the scope of zx.
That means I have to have a package.json next to my-script-file.js, and install dependencies. It also doesn't have access to $(unix-command), I'd have to run exec() in my script file, and then worry about sanitizing those commands.
zx has a bunch of defaults and modules out of the box, so it conveniently lets me make my scripts portable and easier to write without having to worry about a bunch of the boilerplate and legwork I would need if I did node ./my-script-file.js. It's the same argument I guess of using any library over writing it from scratch yourself instead. Convenience. It also comes with the same drawbacks of using libraries, mostly trust issues.
I saw that the other day, I must say I like a lot because it looks similar to a thing I did a while ago. But there is a "missed oportunity" in this tool. The implementation of
$
is not really cross-platform, which is quite a shame. Also, it would be nice if they provide an argument parser likeminimist
orarg
.Yeah, I think it's still very new, and might mature in the future. I have high hopes for it.
I don't usually think about shell scripts as accepting arguments, I usually build CLIs for that use case, with things like
oclif
orjs-fire
. But when I was trying to use arguments inzx
even if for the sake of my example, I did miss a better way to parse arguments thanprocess.argv
. Hopefully it's something they'll add in the near future.Looking throught the issues it does appear like the maintainer wants to keep things as simple as possible. Doesn't look too eager to change things. Anyway, is still a good project.
You know I just remembered something: one can actually install this tool directly from github. So, people could fork this project, tweak a little bit and then install the fork like this.
That would be an interesting use of this
npm install
feature.Oh, that's a really good idea. Especially since the work required would be minimal, for example using
minimist
for arguments would imply adding a few lines for importing the package and exposing it within the scope ofzx
.from zx api docs:
minimist
const argv = minimist(process.argv.slice(2), {})
Sorry I don't get it, but how is that different from executing
node ./my-script-file.js
?That means I have to have a
package.json
next tomy-script-file.js
, and install dependencies. It also doesn't have access to$(unix-command)
, I'd have to runexec()
in my script file, and then worry about sanitizing those commands.zx
has a bunch of defaults and modules out of the box, so it conveniently lets me make my scripts portable and easier to write without having to worry about a bunch of the boilerplate and legwork I would need if I didnode ./my-script-file.js
. It's the same argument I guess of using any library over writing it from scratch yourself instead. Convenience. It also comes with the same drawbacks of using libraries, mostly trust issues.This was a funny one! Especially the math part 😂
Aww, thank you! I do what I can 😅
I don't think I could ever write like that 😃
If you're interested, I wrote a python version that's much cleaner and easier to use (imo) 😉 Available here