Skip to content

Commit 912eb42

Browse files
committed
plugin.ts: Fixes for @code-asher
1 parent c3c64a8 commit 912eb42

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

ci/dev/test.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -euo pipefail
44
main() {
55
cd "$(dirname "$0")/../.."
66

7+
cd test/test-plugin
8+
make -s out/index.js
9+
cd $OLDPWD
710
mocha -r ts-node/register ./test/*.test.ts "$@"
811
}
912

src/node/plugin.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ interface Plugin extends pluginapi.Plugin {
2323
}
2424

2525
interface Application extends pluginapi.Application {
26-
plugin: Plugin
26+
/*
27+
* Clone of the above without functions.
28+
*/
29+
plugin: Omit<Plugin, "init" | "router" | "applications">
2730
}
2831

2932
/**
@@ -57,7 +60,15 @@ export class PluginAPI {
5760
// Add plugin key to each app.
5861
apps.push(
5962
...pluginApps.map((app) => {
60-
return { ...app, plugin: p }
63+
return {
64+
...app,
65+
plugin: {
66+
name: p.name,
67+
version: p.version,
68+
description: p.description,
69+
modulePath: p.modulePath,
70+
},
71+
}
6172
}),
6273
)
6374
}
@@ -74,8 +85,9 @@ export class PluginAPI {
7485
}
7586

7687
/**
77-
* loadPlugins loads all plugins based on this.csPluginPath
78-
* and this.csPlugin.
88+
* loadPlugins loads all plugins based on this.csPlugin,
89+
* this.csPluginPath and the built in plugins.
90+
*
7991
*/
8092
public async loadPlugins(): Promise<void> {
8193
// Built-in plugins.

test/plugin.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ describe("plugin", () => {
1212
const papi = new PluginAPI(logger, path.resolve(__dirname, "test-plugin") + ":meow")
1313
await papi.loadPlugins()
1414

15-
// We remove the function fields from the application's plugins.
16-
const apps = JSON.parse(JSON.stringify(await papi.applications()))
15+
const apps = await papi.applications()
1716

1817
assert.deepEqual(
1918
[

test/test-plugin/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
out/index.js: src/index.ts
2+
yarn build
3+
4+
node_modules: package.json yarn.lock
5+
yarn

0 commit comments

Comments
 (0)