victorb / trymodule

➰ It's never been easier to try nodejs modules!
1.14k stars 29 forks source link

Accept git repos as an argument #18

Closed mie00 closed 7 years ago

victorb commented 8 years ago

Very nice! I was expecting this and tarballs (and other things that NPM supports) to work without effort but seems like there was an issue with the package name being confused with the whole repository URL. This seems like a good solution.

Before merging though, I would like to know what fs.symlink(result.pop()[0].split('@')[0], packageLocation(name), (err) => { does, why and if we can make it a bit more descriptive. It's hard to understand what it does by just looking and not inspecting the output.

mie00 commented 8 years ago

This line fixes the problem that npmi clones the repo under its package name not the repo name. so for a repo like this https://github.com/grncdr/js-shell-parse/ it will be under shell-parse directory cause this is its name in pacakge.json.

So a quick fix for that is to make a link from the expected package directory to the actual directory of the package. So in that case there is a link js-shell-parse => parse-shell.

However, I think that this should be changed to the following.

Another solution is always trying npmi so it updates the repos anyway, and then use the package name that it returns, so in the case of js-shell-parse you it will be cloned under shell-parse as npmi does and shell_parse will be the variable name that you will use inside the REPL.