Describe the bug
When invoking custom actions using Node.js, the arguments passed are mishandled on Windows. Specifically:
Paths to scripts are not escaped, leading to issues when directory names contain spaces.
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.
Additionally, the command node does not recognize globally installed packages, necessitating absolute paths to libraries in scripts.
To Reproduce
Steps to reproduce the behavior:
Set up a custom action in Node.js.
Provide a script path that contains spaces.
Pass a JSON front matter argument enclosed with single quotes.
Run the custom action on both macOS and Windows.
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.
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.
**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.
<!-- github-sync-id:1859295129 -->
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.
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](https://stackoverflow.com/questions/9587665/nodejs-cannot-find-installed-module-on-windows) for more information.
<!-- github-comment-id:1687874874 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Describe the bug
When invoking custom actions using Node.js, the arguments passed are mishandled on Windows. Specifically:
JSON.parseto fail.nodedoes not recognize globally installed packages, necessitating absolute paths to libraries in scripts.To Reproduce
Steps to reproduce the behavior:
JSON.parsewill throw an error due to the missing double quotes in the JSON argument.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):
Additional context
I am using version 8.4.0 of the software.
Thanks @steelcoder for opening the issue.
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.
Thank you @estruyf for your responsiveness 😉