dependency-check icon indicating copy to clipboard operation
dependency-check copied to clipboard

Recurse into files required through the root symlink pattern

Open moll opened this issue 10 years ago • 10 comments
trafficstars

Hello, Max, from Tallinn.

I tend to add a symlink named root to node_modules to require things relative to the app's root directory. Looking like an external module, I assume dependency-check doesn't recurse to those files and won't find require expressions in those files.

You reckon there's a way to teach it about this pattern?

Cheers

moll avatar Jun 20 '15 21:06 moll

I think that will work OK actually (thanks to https://www.npmjs.com/package/resolve). As long as resolve can resolve the require call then everything should work as expected

max-mapper avatar Jun 20 '15 21:06 max-mapper

Well, it doesn't seem to work. I'm suspecting it might have something to do with this relative check on https://github.com/maxogden/dependency-check/blob/f3f7201d6da262e3b9b0dc131381fba23a42c81b/index.js#L133.

        if (IS_NOT_RELATIVE.test(req) && !isCore) {

moll avatar Jun 20 '15 22:06 moll

Ah, as I read the code further, I'm suspecting that guess was hasty and wrong. :innocent: You know the code better. Is this symlink thing working for you?

moll avatar Jun 20 '15 22:06 moll

I'm not sure I have the same exact setup as you, but I also develop from inside a symlinked node_modules folder and my requires get resolved OK

max-mapper avatar Jun 21 '15 23:06 max-mapper

You mean you too have a symlink named, e.g., "root" inside node_modules that links to ".." and then require things as require("root/lib/smth")?

moll avatar Jun 22 '15 00:06 moll

@moll ahhh no that is different. I have a folder called ~/src that contains all my projects, e.g. ~/src/dat, and I have a symlink at ~/node_modules that points at ~/src (because src is easier to type). That way if I am in ~/node_modules/dat and I want to use a development copy of e.g. dat-core I can rm -rf ~/src/dat/node_modules/dat-core and then the git tracked copy of dat-core located at ~/src/dat-core will get used instead

max-mapper avatar Jun 22 '15 17:06 max-mapper

That's clever too.

But, yeah, I was talking about that other pattern, hence the question on how to get that working. :)

moll avatar Jun 22 '15 17:06 moll

Hmm in that case I'm not sure really... there might be a special case that could be added to handle that in this module, or it might be something that needs to be fixed upstream. I don't have a ton of time to dive into it now, but if you can figure out a nice solution I'd happily merge

max-mapper avatar Jun 22 '15 17:06 max-mapper

I'm not sure I have the time right now to delve deep either, but let's race for it. :-)

moll avatar Jun 22 '15 19:06 moll

If I'm reading this correct, all it'd be is exposing paths from resolve, right? That way it falls back to hard-coded paths to search on.

blakeembrey avatar Apr 12 '17 01:04 blakeembrey