mixu/gluejs

indirection breaks API relative paths

athibaud opened this issue · 2 comments

commit 6656c05 changed package.json's main from lib/glue.js to lib/index.js (which in turn requires lib/glue.js)

while using the API rather than the binary, that causes this line:

reqpath: path.dirname(require.cache[__filename].parent.filename)

in lib/glue.js to evaluate to ./gluejs/lib/index.js as opposed to the path of the js file in which new Glue() is invoked...
that messes up relative includes in gluejs's API (e.g.: new Glue().include('../somedir')).

I tried simply changing the line to

reqpath: path.dirname(require.cache[__filename].parent.parent.filename)

so that the proper filename is fetched by following the indirection (main is lib/index.js now which then requires lib/glue.js so we have to reach to the parent of the parent... parent.parent), but that breaks the new gluejs binary (bin/gluejs).
sorry if the issue isn't too clear hehe.

mixu commented

Thanks for reporting this and sorry it took me this long to get back to you. The issue should be fixed now.

no worries, thanks for fixing! did a quick test on my projet and it seems to be functional!
npm package update would be cool. thanks again.