-
Notifications
You must be signed in to change notification settings - Fork 48
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
Refactor to ES6 #10
Refactor to ES6 #10
Conversation
This is rebased and ready to go. Note, I replicated the existing functionality of
But, you can't actually get that array from
In which case you get that ^ as a string. So, i think we should reconsider how args are parsed, in another PR. Might be a good idea to consider something like |
@nfischer cc |
} | ||
// ['foo; bar', 'baz;quz', 'qux'] => [['foo'], ['bar', 'baz'], ['quz', 'qux']] | ||
const parseArgs = (args) => args | ||
.join(' ') // ['foo; bar baz;quz qux'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work.
Imagine I invoke shx with something like this:
shx rm -rf "dir with spaces"
This should result in shell.rm('-rf', 'dir with spaces');
, but with this it will become shell.rm('-rf', 'dir', 'with', 'spaces');
@levithomason: You could get that by doing |
Right you are. I'd like to pause here for tests actually. I'd be much more comfortable with test cases for these. How about you? |
Me too... I have some, let me push to master |
Dammit... I don't know where the tests went, I suppose the got deleted. I'll try to re-write them tonight. |
Cool, I'm also testing some approaches here. let's compare soon. What is the use case for the semicolon? |
Reason I ask, using a semicolon requires quoting the command to prevent the shell running
It doesn't seem like that intuitive or useful of a feature, imo. If not for the semicolon parsing, I believe
Is there a semicolon use case that is a big enough win to have an arg parser? |
Assuming we want to create and remove a file: # I like this
$ shx touch file.txt ; shx rm file.txt
# I don't like this
$ shx "touch file.txt;rm file.txt" Why over complicate? I'm assuming semicolon has the same behavior on Windows, of course. |
Hmm... That's a good point. The semicolon would get caught by the Shell. Maybe I like this$ shx touch file.txt ; shx rm file.txt I don't like this$ shx "touch file.txt;rm file.txt" Why over complicate? I'm assuming semicolon has the same behavior on Windows, of — |
Cool beans, totally agreed. Since I'll update this PR to use the simplified method then and we'll truck on! Thanks. |
@@ -1,3 +1,5 @@ | |||
#!/usr/bin/env node | |||
var shx = require('./shx'); | |||
import 'babel-polyfill'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Polyfill needs to be included in the entry point. We don't yet have bundles so I am treating the cli as the entry point. This lets us use future native features, like the includes
method for arrays.
OK, we should be all set now. Dropped parseArgs and updated all to ES6. |
@levithomason: could I ask you to squash your commits, and have them comply to the angular commit message conventions? Thanks so much! |
Added support for future It didn't seem like all those should be squashed, but LMK if you disagree and I'll squash 'em. |
I don't care as much about squashing commits. They seem unrelated enough that we can keep them as-is. |
Agreed. |
LGTM! |
This PR:
/src/parseArgs.js
to ES6 syntaxairbnb
(instead of legacy)