-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Add .escapedCommand
property
#466
Conversation
Great to see this happening! I'm a fan of being able to pass the const execa = require('execa');
(async () => {
const { command } = await execa('echo', ['unicorns']);
await execa.command(command); // works
})();
|
The discussion in #455 resolved towards a different purpose though: returning a string for debugging purpose (per @sindresorhus comment here), not to re-use programmatically. Re-using the same command + arguments programmatically can already be achieved by using variables to store them, or by refactoring similar code into single functions (see my previous comment).
This might actually be an argument against using the name |
My comment was specifically about your no. 2 suggestion above, i.e., changing But I understand it's slightly controversial, and all your suggestions like |
My bad, I am realizing my comment was not clear. By So by |
Got it, thanks for the explanation, it was at least partially a misunderstanding on my end 😄. |
I would go with renaming it to |
Fixed 👍 |
index.d.ts
Outdated
Same as `command` but escaped. | ||
|
||
This is meant to be copy/pasted in a shell, for debugging purpose. | ||
Since the escaping is fairly basic, this should be passed to neither `execa()` nor `execa.command()` |
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.
To prevent any vulnerability report coming from this, I think we should say that it should not be used with any child process type method. Same with .command
.
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.
Fixed 👍
Co-authored-by: Sindre Sorhus <[email protected]>
Co-authored-by: Sindre Sorhus <[email protected]>
Closes #455.
This adds a
debugString
property to the return value and error instances, as described in the above issue.As I implemented this, I realized that this property is very similar to the existing
command
property. What are your thoughts on either of the following options?debugString
toescapedCommand
orquotedCommand
to reflect this.command
property instead. This would be a breaking change.