Skip to content

Commit

Permalink
feat: follow symlinks in dependency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Oct 17, 2019
1 parent 40f8d9a commit 754038c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/dependency-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ function gatherImported() {

for (const {imports} of dependencyGraph.values()) {
for (const [importedFilename, importedIdentifiers] of imports) {
filenames.add(importedFilename)
// require.resolve will expand any symlinks to their fully qualified
// directories. We can use this (with the absolute path given in
// importedFilename to quickly expand symlinks, which allows us to have
// symlinks (aka workspaces) in node_modules, and not fail the lint.
const fullyQualifiedImportedFilename = require.resolve(importedFilename)
filenames.add(fullyQualifiedImportedFilename)

for (const importedIdentifier of importedIdentifiers) {
identifiers.add(`${importedFilename}#${importedIdentifier}`)
identifiers.add(`${fullyQualifiedImportedFilename}#${importedIdentifier}`)
}
}
}
Expand Down

0 comments on commit 754038c

Please sign in to comment.