sanack / node-jq

Node.js wrapper for jq
MIT License
276 stars 51 forks source link

[FIX] WIndows binary #671

Open dupasj opened 5 months ago

dupasj commented 5 months ago

I encountered issues when running the node-jq binary from the package. I discovered that if you don't append .exe to the bin package file path, the binary isn't added/symlinked in the node_module/.bin/ repository, resulting in the binary not being resolved.

In response to this issue, I've added the renamePackageBin function, which forces to assign the full filename as the binary file in the package.json, resolving the problem.

I've executed this function in all OS contexts, which should work, but we can consider guarding it for Windows only (when the filename ends by .exe, for example).

dupasj commented 4 months ago

Can we make sure this works fine in Windows on CI?

I do not have access to your CI or I cannot see the CI, can you please me prompt me the error if you have ?

dupasj commented 4 months ago

Hi @davesnx !

After some tests, I found out that when you reinstall the dependency, the binary file is welly symbolinked.

It's look like the binary symbolink are created before the preinstall hooks (so if the file is not already downloaded, the symbolink is ignored.) So I force it by running "npm link ." in the package folder after the file download (take a look at this commit).

Note that I also change the test unit: I had to replace "null" with "undefined" in some places.