Skip to content
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
18 changes: 4 additions & 14 deletions apps/daemon/src/plugins/plugin-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ function tracked(enabled = 'enable'): string {
return `
import { events } from '../../../../recorder.mjs';
export default ({ id }) => ({
onEnable() {
onEnable(scope) {
events.push(\`${enabled} \${id}\`);
return [() => events.push(\`dispose \${id}\`)];
},
onDisable() {
events.push(\`disable \${id}\`);
scope.add(() => events.push(\`dispose \${id}\`));
},
});
`;
Expand Down Expand Up @@ -188,7 +185,7 @@ describe('load', () => {
await store.load('@test/a');
await store.enable('@test/a', {});

expect(events).toEqual(['one @test/a', 'disable @test/a', 'dispose @test/a', 'two @test/a']);
expect(events).toEqual(['one @test/a', 'dispose @test/a', 'two @test/a']);
});
});

Expand Down Expand Up @@ -328,14 +325,7 @@ describe('disableAll', () => {

await store.disableAll();

expect(events).toEqual([
'enable @test/a',
'enable @test/b',
'disable @test/b',
'dispose @test/b',
'disable @test/a',
'dispose @test/a',
]);
expect(events).toEqual(['enable @test/a', 'enable @test/b', 'dispose @test/b', 'dispose @test/a']);
expect(store.plugins.map((plugin) => plugin.status)).toEqual(['disabled', 'disabled']);
});
});
6 changes: 2 additions & 4 deletions apps/daemon/src/plugins/plugin-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { type EnabledSnapshot, type InstalledPlugin, type InvalidPlugin, PluginResolver } from '@elsewise/core';
import { readPluginsSync } from '@elsewise/core/node';
import type { Daemon, Disposable, Plugin } from '@elsewise/daemon-plugin';
import type { Daemon, Plugin } from '@elsewise/daemon-plugin';
import type { DataDirectory } from '../directories';
import { TARGET, VERSION } from '../global';

Expand Down Expand Up @@ -44,9 +44,7 @@ export class PluginStore extends PluginResolver<InstalledPlugin, Daemon, Plugin,
return { ...plugin, url: pathToFileURL(path.join(this.data.plugins, id, 'daemon', daemon.main)).href };
}

protected onEnable(): readonly Disposable[] {
return [];
}
protected onEnable(): void {}

protected describe(_plugin: InstalledPlugin, snapshot: EnabledSnapshot): EnabledSnapshot {
return snapshot;
Expand Down
6 changes: 2 additions & 4 deletions apps/daemon/test/daemon.bundle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,9 @@ async function installPlugin(data: string): Promise<void> {
`
import fs from 'node:fs';
export default () => ({
onEnable() {
onEnable(scope) {
fs.writeFileSync(new URL('./enabled', import.meta.url), '');
},
onDisable() {
fs.writeFileSync(new URL('./disabled', import.meta.url), '');
scope.add(() => fs.writeFileSync(new URL('./disabled', import.meta.url), ''));
},
});
`,
Expand Down
Loading
Loading