npm creates incorrect cmd shim for jezebel package on windows #3380
Comments
The source code for cmd-shim is here and a pull request to fix this would be welcome. However, it should be easier in this case to just make jezebel not do that, since there's no real reason why it would need to do that. |
I'll try to create a fix. I see your point but I think it's best if the shim creation either fails if it can not extract the command from the file successfully or handles the given case correctly. My proposal would be to go for the latter option. |
It looks like Jezebel is trying to use NODE_PATH as a polyfill for the now-removed require.paths. That is not supported, recommended, safe, or guaranteed to work reliably. You should report the bug to them. |
Note: I do acknowledge that this is a bug in cmd-shim, but like many bugs, it's not worth fixing until and unless there's a real need for it, because the fix adds complexity. |
As you can see I reported the issue to jezebel, do you see a legitimate reason to add support for the use of variables in cmd-shim? |
Yes, in this case it's definitely a higher priority to just fix jezebel. One option would be to just fix |
- Adapt the regular expression used to match the first line. - Create a simple module that can convert shell style variable declarations: NODE_PATH=./lib:$NODE_PATH to the equivalent batch syntax: @set=NODE_PATH=./lib:%NODE_PATH%. Furthermore the structure of the generated shim now looks like this: @SETLOCAL <variable declarations> <original content> @endlocal - Note that the new segments are only added to the file if there were any variable declarations. - The generated shell script carries over the captured variable declaration as is. - Add some extra tests to validate the behavior. - Remove some unnecessary white-space in the generated shim. PR-URL: #2 Fix: npm/npm#3380 Credit: @basbossink Close: #2 Reviewed-by: @isaacs
When trying to run jezebel on windows after installing it with npm, it fails. C:\Users\AppData\Roaming\npm\jezebel.cmd looks like this:
Which is syntactically incorrect.
Looking at the jezebel repository the bin\jezebel file has the following first line:
Looking at the npm source code, specifically node_modules\cmd-shim:22 shows:
This regular expression was not built with the possibillity of variable declarations in mind.
It should be adapted to extract the variable declarations and translate them to the proper
cmd
syntax:in this case.
The text was updated successfully, but these errors were encountered: