-
Notifications
You must be signed in to change notification settings - Fork 619
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
fix: installed module can not get arguments correctly #510
Conversation
/cc @ry |
installer/mod.ts
Outdated
@@ -153,7 +153,7 @@ async function generateExecutable( | |||
filePath: string, | |||
commands: string[] | |||
): Promise<void> { | |||
commands = commands.map((v): string => '"' + v + '"'); | |||
commands = commands.map((v): string => `"${v.replace(/\"/g, '\\"')}"`); |
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.
Hrm... I don't think this is sufficient to escape the strings properly. (I can't immediately think of a counter example...) What about using JSON.stringify() on the strings?
commands = commands.map(JSON.stringify);
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.
yes, it works.
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.
You can leave out the anonymous function I think.
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.
@ry No, it can't. typescript compiler will throw an 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.
LGTM
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
The generated command is not wrapped in double quotes
This will cause the parameters passed to the script to be incorrect
change: