Skip to content

Commit

Permalink
fix: module resolution of linked plugins (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Jan 28, 2022
1 parent 9ab63aa commit c7f5d34
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/config/config.ts
Expand Up @@ -281,7 +281,13 @@ export class Config implements IConfig {
debug('runCommand %s %o', id, argv)
const c = cachedCommand || this.findCommand(id)
if (!c) {
await this.runHook('command_not_found', {id, argv})
const hookResult = await this.runHook('command_not_found', {id, argv})

if (hookResult.successes[0]) {
const cmdResult = hookResult.successes[0].result
return cmdResult as T
}

throw new CLIError(`command ${id} not found`)
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Expand Up @@ -83,7 +83,7 @@ async function findRoot(name: string | undefined, root: string) {
if (name) {
let pkgPath
try {
pkgPath = resolvePackage(name, {paths: [__dirname, root]})
pkgPath = resolvePackage(name, {paths: [root]})
} catch {}

return pkgPath ? findSourcesRoot(path.dirname(pkgPath)) : findRootLegacy(name, root)
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/hooks.ts
Expand Up @@ -35,7 +35,7 @@ export interface Hooks {
};
'command_not_found': {
options: {id: string; argv?: string[]};
return: void;
return: unknown;
};
'plugins:preinstall': {
options: {
Expand Down

0 comments on commit c7f5d34

Please sign in to comment.