Skip to content

refactor: add wrapOutput option to auto-ShellString-ify command output#481

Merged
nfischer merged 1 commit intomasterfrom
refactor-shellstring-return-value
Jul 25, 2016
Merged

refactor: add wrapOutput option to auto-ShellString-ify command output#481
nfischer merged 1 commit intomasterfrom
refactor-shellstring-return-value

Conversation

@nfischer
Copy link
Copy Markdown
Member

This lets you return a plain JS string (like before), but pass the wrapOutput option to common.register() in order to wrap this string in a ShellString. This wraps it with the following default parameters (which I think will work properly most of the time):

return myReturnValue;
// This gets wrapped to imitate the statement:
return new common.ShellString(myReturnValue, common.state.error, common.state.errorCode);
// If any errors have occurred, put these in the .stderr attribute
// Whatever the resulting exit code is (0 unless there's an error), set that for the .code attribute

By default, common.register() works as before (so collaborators must opt-in for this feature). This lets functions return non-string output, or return a custom-built ShellString (if these default values aren't suitable).

Do not merge until after #479 is either closed or merged

@ariporad
Copy link
Copy Markdown
Contributor

LGTM!

@nfischer nfischer force-pushed the refactor-shellstring-return-value branch from 467a10d to 0a8cacf Compare July 25, 2016 01:06
@nfischer
Copy link
Copy Markdown
Member Author

This is just updated to resolve the conflicts introduced by #479. I'm going to re- LGTM this, since it's pretty trivial.

@nfischer nfischer merged commit 9c7e6a8 into master Jul 25, 2016
@nfischer nfischer deleted the refactor-shellstring-return-value branch July 25, 2016 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants