Skip to content

Commit

Permalink
feat: support remove plugin (#677)
Browse files Browse the repository at this point in the history
* feat: support remove plugin

* fix: fix error

* chore: add changeset

* chore: remove changeset

---------

Co-authored-by: nyqykk <[email protected]>
  • Loading branch information
nyqykk and nyqykk authored Jul 16, 2024
1 parent 6d8ac4d commit c38d6fe
Show file tree
Hide file tree
Showing 4 changed files with 5,469 additions and 6,120 deletions.
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

0 comments on commit c38d6fe

Please sign in to comment.