zotero-connectors
zotero-connectors copied to clipboard
Fix CYGWIN/Gulp path issue in build.sh
There is an apparent path related issue with Gulp when called via absolute path under CYGWIN. The issue does not occur if relative path is used.
Any patch needs to include a detailed justification — it's not enough to say "an apparent path related issue". Otherwise we're just accumulating cruft that could never be removed.
What's the actual error you're receiving? If the current directory has a space in it, the current code would fail, unrelated to the platform, because the path isn't quoted. Doing that would be a better fix.
While in ./zotero-connectors, if I run
/cygdrive/c/Users/pcuser/WebstormProjects/zotero/zotero-connectors/node_modules/gulp/bin/gulp.js -v
it throws (I indicated with bold the indication of messed up path conversion)
internal/modules/cjs/loader.js:979 throw err; ^
Error: Cannot find module 'C:\cygdrive\c\Users\pcuser\WebstormProjects\zotero\zotero-connectors\node_modules\gulp\bin\gulp.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:976:15) at Function.Module._load (internal/modules/cjs/loader.js:859:27) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }
If I run
./node_modules/gulp/bin/gulp.js -v
it produces the expected output.
Hoping not to add to confusion ... two of us have worked through this over at Jurism. We wanted to have smooth connector builds running in Linux and in Windows, and here's what we've come up with. This differs a bit from this PR, but addresses the same issues. We're happy in our fork, but if it will help we can either put up a separate PR or leave it with the description below.
When building under Cygwin, the copy of node used for the build is installed under Windows (it isn't a Cygwin application). Given a relative path at the command line, it will extend its native Windows PWD, but if given an absolute path, it's passed through verbatim, and if that's a Unix path, things will break. To avoid relying on implicit magic inside the Windows node binary, the absolute Cygwin path can be specified with "$(pwd | xargs cygpath -w)
.
In the patch to gulpfile.js
, node's path
module gives us delimiter arbitration for free, so with const pth = require('path');
at the top of the file, the forward slashes at the top of processFile
can just be replaced with pth.sep
, and the files will be processed okay.