Skip to content

Commit

Permalink
See #58. Fix bug in NodeDependency error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Apr 7, 2018
1 parent e5f7973 commit e2220b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/DependencyManager/NodeDependency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ export class NodeDependency extends Dependency {

// tslint:disable-next-line:no-reserved-keywords
private require(id?: string): any {
const modulePath = this.resolve(id);
const path = this.fullPath(id);
const modulePath = this.resolve(path);
if (modulePath) {
// tslint:disable-next-line:no-require-imports non-literal-require
return require(modulePath);
} else {
throw new Error(`Cannot find module ${id}`);
throw new Error(`Cannot find module ${path}`);
}
}

private resolve(file?: string): string | undefined {
const path = this.fullPath(file);
private resolve(path: string): string | undefined {
return this.resolveLocal(path) || this.resolveGlobal(path);
}

Expand Down
2 changes: 1 addition & 1 deletion test/DependencyManager/DependencyManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test("should fail to load dependencies", async () => {
expect(error.message).toMatch(
'Dependency "NotFound" is required and not installed.'
);
expect(error.message).toMatch("Cannot find module package.json");
expect(error.message).toMatch("Cannot find module notfound/package.json");
});
});

Expand Down
6 changes: 3 additions & 3 deletions test/DependencyManager/NodeDependency.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test("should fail to load Node dependency", async () => {
expect.assertions(5);
const options: DependencyOptions = {
name: "NotFound",
package: "NotFound",
package: "notfound",
type: DependencyType.Node,
};
const dependency = new NodeDependency(options);
Expand All @@ -17,12 +17,12 @@ test("should fail to load Node dependency", async () => {
expect(error.message).toMatch(
'Dependency "NotFound" is required and not installed.'
);
expect(error.message).toMatch("Cannot find module package.json");
expect(error.message).toMatch("Cannot find module notfound/package.json");
expect(dependency.isInstalled).toBe(false);
expect(dependency.errors).toHaveLength(1);
expect(error.message).toMatch(
'Dependency "NotFound" is required and not installed.\n' +
" - Cannot find module package.json"
" - Cannot find module notfound/package.json"
);
});
});
Expand Down

0 comments on commit e2220b0

Please sign in to comment.