Permalink
Browse files

actually fix #4

it turns out I had forgotten CommonJS had this thing
where you didn't have to specify the file extension
when requiring, so just relying on the required string
would yield filenames without extensions and mismatches.
  • Loading branch information...
fiatjaf committed Jul 12, 2017
1 parent 392fb2e commit 9e3ccf833d1ec1420565ffe56dc69d24c3b813f1
Showing with 9 additions and 1 deletion.
  1. +8 −1 dependency-tree.js
  2. +1 −0 package.json
View
@@ -2,6 +2,7 @@ const fs = require('fs')
const glob = require('glob')
const path = require('path')
const uniq = require('array-unique')
const resolve = require('resolve-from')
const precinct = require('precinct')
module.exports = function (base) {
@@ -28,7 +29,13 @@ function inspect (file, base) {
if (req[0] !== '.') {
deps.push([filerel, 'external', req])
} else {
let rel = '.' + path.resolve(path.dirname(file), req).slice(base.length)
var resolved
try {
resolved = resolve(path.dirname(file), req)
} catch (e) {
resolved = path.resolve(path.dirname(file), req)
}
let rel = '.' + resolved.slice(base.length)
deps.push([filerel, 'local', rel])
}
}
View
@@ -11,6 +11,7 @@
"md5": "^2.2.1",
"mkdirp": "^0.5.1",
"precinct": "^3.6.0",
"resolve-from": "^3.0.0",
"rmr": "0.0.4",
"viz.js": "^1.8.0"
},

0 comments on commit 9e3ccf8

Please sign in to comment.