-
Notifications
You must be signed in to change notification settings - Fork 743
Refactor shellstring #360
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 shellstring #360
Conversation
|
@nfischer: Maybe I'm missing something, but how is returning a Also, what are your thoughts on converting them to |
|
@ariporad Convering in common.wrap is fine with me, as long as it works. JavaScript has |
4d31e86 to
995f031
Compare
|
This still isn't ready to merge. I'll ping this thread when it's ready for review. |
|
@ariporad Please take a look at my implementation. This is quite a big refactor, but I think it has some nice benefits.
We can also consider extending this type to have a cat('file.txt').forEach(function (line) {
echo(" " + line);
}); // indent every line of the file in stdoutThis might make it easy to refactor |
src/common.js
Outdated
| that.to = wrap('to', _to, {idx: 1}); | ||
| that.toEnd = wrap('toEnd', _toEnd, {idx: 1}); | ||
| that.stdout = str; | ||
| that.stderr = typeof stderr !== 'undefined' ? stderr : state.error; |
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.
I don't think we should default to state.error here, because:
var str = ShellString('foo');
str.stderr; // This should be null, having it be anything else wouldn't make any sense.
str.to('foo.txt');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.
The rationale was for commands like sed(), which can sometimes have stderr output, and still return a value (imagine one file exists, and one file doesn't exist).
One alternative would be to not default it, but to have each call to ShellString() explicitly have a stderr argument if it needs it.
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.
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.
Done. Will push in a second
b1814aa to
9e6e0c2
Compare
|
@nfischer: Is it possible to convert the result to a |
|
@ariporad I thought about putting it in |
|
Ok. LGTM! Ari On Fri, Feb 19, 2016 at 3:25 PM, Nate Fischer notifications@github.com
|
9e6e0c2 to
cd04c29
Compare
- fix(string): no longer overrides string prototype - exec() now returns a ShellString object
cd04c29 to
6ebc2d3
Compare
|
@ariporad Ok, the issues should be resolved now. LGTM, feel free to merge |
|
@ariporad I went ahead and added some of these methods to the array returned by If everything looks good, feel free to squash the changes together (or not, doesn't matter to me), and merge. After this is merged, I can redo #269 so that each ShellString also has a |
|
@nfischer: One small nit, but it's not that big a deal, so I'll say LGTM. As for the |
|
Merge at will. |
refactor(ShellString): refactor shellstring
This is a PR to refactor commands to return
ShellStringobjects instead of regular strings. This still has some broken tests, so it's far from ready, but I think in principle this approach will work.Feel free to fix any tests and/or post the diffs.
Fixes #356, #154.