Protect against edge case when resolved is a string.

In particular, if the "main" field of the package.json file cannot be
resolved, then the `resolved` variable will be "missing", which is a
truthy value that silently rejects property assignments. Ugh!
This commit is contained in:
Ben Newman
2017-02-15 13:57:43 -05:00
parent af51d1f216
commit c2e4b77636

View File

@@ -316,7 +316,7 @@ export default class Resolver {
const resolved = this._joinAndStat(dirPath, main) ||
this._resolve(main, pkgJsonPath, _seenDirPaths);
if (resolved) {
if (resolved && typeof resolved === "object") {
if (! resolved.packageJsonMap) {
resolved.packageJsonMap = Object.create(null);
}