Skip to content
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

Issue: Arguments passed to custom actions in Node are improperly formatted on both MacOs and Windows #628

Closed
steelcoder opened this issue Aug 21, 2023 · 3 comments
Labels

Comments

@steelcoder
Copy link

Describe the bug
When invoking custom actions using Node.js, the arguments passed are mishandled on Windows. Specifically:

  1. Paths to scripts are not escaped, leading to issues when directory names contain spaces.
  2. The JSON argument for front matter, when escaped with single quotes, behaves differently between macOS and Windows. On Windows, the argument loses its double quotes when passed, causing JSON.parse to fail.
  3. Additionally, the command node does not recognize globally installed packages, necessitating absolute paths to libraries in scripts.

To Reproduce
Steps to reproduce the behavior:

  1. Set up a custom action in Node.js.
  2. Provide a script path that contains spaces.
  3. Pass a JSON front matter argument enclosed with single quotes.
  4. Run the custom action on both macOS and Windows.
  5. Observe that on Windows, the script may fail due to spaces in the directory name and JSON.parse will throw an error due to the missing double quotes in the JSON argument.
  6. Also, note the inability to recognize globally installed packages.

Expected behavior
Arguments should be consistently and correctly passed to custom actions across different operating systems. Paths should be escaped to handle spaces, and JSON arguments should retain their original formatting. Also, globally installed Node.js packages should be recognized without the need for absolute paths.

Screenshots
N/A

Desktop (please complete the following information):

  • Windows 10 & 11 (x64), MacOs 13.5 (Apple Silicon)

Additional context
I am using version 8.4.0 of the software.

@steelcoder steelcoder added the bug Something isn't working label Aug 21, 2023
@estruyf
Copy link
Owner

estruyf commented Aug 22, 2023

Thanks @steelcoder for opening the issue.

estruyf added a commit that referenced this issue Aug 22, 2023
@estruyf
Copy link
Owner

estruyf commented Aug 22, 2023

I have added a fix for the paths with spaces and JSON arguments on Windows.

About the node command not recognizing globally installed packages, this is a configuration on the local machine. By default, node will not retrieve global modules; you must ensure the global node_modules folder is set in the path environment variable. Check StackOverflow issue for more information.

@steelcoder
Copy link
Author

Thank you @estruyf for your responsiveness 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants