Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support remove plugin #677

Merged
merged 4 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"cy:open": "cypress open --config-file=cypress.config.ts",
"cy:run": "cypress run",
"type:check": "tsc -noEmit",
"changeset": "npx changeset",
"reset": "pnpm -r exec -- rm -rf node_modules && pnpm -r exec -- rm -rf dist && rm -rf node_modules",
"setup": "cross-env DISABLE_GARFISH_CHECK_INTERNAL=true pnpm install",
"ls-lint": "ls-lint",
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/garfish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ export class Garfish extends EventEmitter2 {
return this;
}

removePlugin(pluginName: string) {
this.hooks.removePlugin(pluginName);
}

run(options: interfaces.Options = {}) {
if (this.running) {
if (__DEV__) {
Expand Down
8 changes: 5 additions & 3 deletions packages/hooks/src/pluginSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@ export class PluginSystem<T extends Record<string, any>> {
const plugin = this.registerPlugins[pluginName];
assert(plugin, `plugin "${pluginName}" is not registered.`);

for (const key in plugin) {
if (key === 'name') continue;
this.lifecycle[key].remove(plugin[key as string]);
for (const key in this.lifecycle) {
const pluginLife = plugin[key as string];
if (pluginLife) {
this.lifecycle[key].remove(pluginLife);
}
}
}

Expand Down
Loading
Loading