UNPKG

@oebot/core

Version:

能跑就行的 QQ 机器人框架,基于 oicq v2,改自KiviBot(R.I.P.)

31 lines (30 loc) 1.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.killPlugin = void 0; const node_path_1 = __importDefault(require("node:path")); /** 从 require 缓存中删除对应模块路径的插件缓存 */ function killPlugin(modulePath) { // 确保路径和 cache 中的 key 一致 const mainPath = require.resolve(modulePath); const mod = require.cache[mainPath]; if (!mod) { return; } const idx = require.main?.children.indexOf(mod); if (idx >= 0) { require.main?.children.splice(idx, 1); } for (const fullPath in require.cache) { const modId = require.cache[fullPath]?.id; const valid = modId?.startsWith(mod.path); if (valid) { delete require.cache[fullPath]; } } delete require.cache[mainPath]; delete require.cache[node_path_1.default.join(modulePath, 'package.json')]; } exports.killPlugin = killPlugin;