From 7d77728eb4625e43930e50827bfcc86c5d560294 Mon Sep 17 00:00:00 2001 From: Shigma <1700011071@pku.edu.cn> Date: Sat, 18 Apr 2020 18:36:55 +0800 Subject: [PATCH] fix(cli): check require stack when encountered with MODULE_NOT_FOUND --- packages/koishi-cli/src/worker.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/koishi-cli/src/worker.ts b/packages/koishi-cli/src/worker.ts index af2c13d960..962341447e 100644 --- a/packages/koishi-cli/src/worker.ts +++ b/packages/koishi-cli/src/worker.ts @@ -4,7 +4,7 @@ import { capitalize } from 'koishi-utils' import { performance } from 'perf_hooks' import { cyan, yellow } from 'kleur' import { logger } from './utils' -import { format, types } from 'util' +import { format } from 'util' import { readFileSync } from 'fs' import { safeLoad } from 'js-yaml' @@ -72,7 +72,7 @@ function loadEcosystem (type: string, name: string) { try { return require(name) } catch (error) { - if (error.code !== 'MODULE_NOT_FOUND') { + if (error.code !== 'MODULE_NOT_FOUND' || error.requireStack[0] !== __filename) { throw error } }