where-used analysis?

33 views
Skip to first unread message

Gregg Caines

unread,
Jan 8, 2015, 4:20:17 PM1/8/15
to nod...@googlegroups.com
Hey all... does anyone have a solution for detecting where/if a file is required in a large codebase?  Manually grepping for it gets old pretty quickly when there can be a difference in relative paths.  I can't find anything like this in npm so I was thinking I could write such a thing using https://github.com/substack/module-deps , but I thought I'd check here first.

Thanks!

G     

Clarkie

unread,
Jan 12, 2015, 3:55:46 AM1/12/15
to nod...@googlegroups.com
You could use something like a code coverage tool like Istanbul but this won't work unless you are testing thoroughly. Also, just because you have a test for something doesn't mean it is still 'required'.

In the past I've used 404 handlers to try and get a handle on a legacy front end code base by doing the following:

1. copy all files to a new location (./old)
2. delete all existing files (./clean is now empty)
3. a request comes in for file ./clean/x.js
4. if not found (404) then copy the file from ./old/x.js to ./clean/x.js and return the contents of the file. 
5. subsequent requests will just return the file as it will be found so no 404 error.

We ran this in production for 3 months and only missed 2 or 3 very rarely used files. A hit rate of 99.9+%.

Perhaps this technique could work here too?
Reply all
Reply to author
Forward
0 new messages