Skip to content

Commit

Permalink
Use pkg-dir instead of findRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
le0nik committed May 17, 2016
1 parent 0cad4e7 commit d53e45f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"gulp-mocha": "^2.2.0",
"istanbul": "^0.4.0",
"mocha": "^2.2.1",
"pkg-dir": "^1.0.0",
"redux": "^3.0.4",
"rimraf": "2.5.2"
},
Expand All @@ -71,7 +72,6 @@
"es6-set": "^0.1.4",
"es6-symbol": "*",
"eslint-import-resolver-node": "^0.2.0",
"find-root": "^1.0.0",
"is-absolute": "^0.2.5",
"lodash.cond": "^4.3.0",
"lodash.endswith": "^4.0.1",
Expand Down
11 changes: 5 additions & 6 deletions src/core/resolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'es6-symbol/implement'
import Map from 'es6-map'
import Set from 'es6-set'
import assign from 'object-assign'
import findRoot from 'find-root'
import pkgDir from 'pkg-dir'
import isAbsoluteFallback from 'is-absolute'

import fs from 'fs'
Expand Down Expand Up @@ -57,7 +57,6 @@ function fileExistsWithCaseSync(filepath, cacheSettings) {
}

export function relative(modulePath, sourceFile, settings) {

const sourceDir = dirname(sourceFile)
, cacheKey = sourceDir + hashObject(settings) + modulePath

Expand All @@ -83,10 +82,10 @@ export function relative(modulePath, sourceFile, settings) {
function v1() {
try {
const path = resolver.resolveImport(modulePath, sourceFile, config)
if (path === undefined) return { found: false }
return { found: true, path }
if (path === undefined) return { found: false, path: null }

This comment has been minimized.

Copy link
@benmosher

benmosher Jun 3, 2016

Member

oh crap, this is super wrong

return { found: true, path: null }
} catch (err) {
return { found: false }
return { found: false, path: null }
}
}

Expand Down Expand Up @@ -156,7 +155,7 @@ function requireResolver(name, modulePath) {

try {
// Try to resolve package with path, relative to closest package.json
const packageDir = findRoot(resolve(modulePath))
const packageDir = pkgDir.sync(resolve(modulePath))

return require(join(packageDir, name))
} catch (err) {
Expand Down

0 comments on commit d53e45f

Please sign in to comment.