dependency-check
dependency-check copied to clipboard
Recurse into files required through the root symlink pattern
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
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
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) {
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?
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
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 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
That's clever too.
But, yeah, I was talking about that other pattern, hence the question on how to get that working. :)
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
I'm not sure I have the time right now to delve deep either, but let's race for it. :-)
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.