Skip to content

Commit 3662ef9

Browse files
author
Sebastian McKenzie
committed
add case for non-existent package.json to kpm check
1 parent 151ea37 commit 3662ef9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cli/commands/check.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,13 @@ export async function run(
8484
let human = path.relative(path.join(process.cwd(), "node_modules"), loc);
8585
human = human.replace(new RegExp(`${path.sep}node_modules${path.sep}`, "g"), " > ");
8686

87-
if (!(await fs.exists(loc))) {
88-
reporter.error(`Module not installed: ${human}`);
87+
let pkgLoc = path.join(loc, "package.json");
88+
if (!(await fs.exists(loc)) || !(await fs.exists(pkgLoc))) {
89+
reporter.error(`Module ${human} not installed`);
8990
valid = false;
9091
}
9192

92-
let pkg = await fs.readJson(path.join(loc, "package.json"));
93+
let pkg = await fs.readJson(pkgLoc);
9394

9495
let deps = Object.assign({}, pkg.dependencies, pkg.devDependencies, pkg.peerDependencies);
9596

@@ -111,6 +112,7 @@ export async function run(
111112
`Module ${human} depends on ${name} with the range ${range} but it doesn't match the ` +
112113
`installed version of ${depPkg.version}`
113114
);
115+
valid = false;
114116
}
115117
}
116118
}

0 commit comments

Comments
 (0)