plugin.ts: Fixes for @code-asher
This commit is contained in:
parent
f4d7f00033
commit
75e52a3774
|
@ -4,6 +4,9 @@ set -euo pipefail
|
||||||
main() {
|
main() {
|
||||||
cd "$(dirname "$0")/../.."
|
cd "$(dirname "$0")/../.."
|
||||||
|
|
||||||
|
cd test/test-plugin
|
||||||
|
make -s out/index.js
|
||||||
|
cd $OLDPWD
|
||||||
mocha -r ts-node/register ./test/*.test.ts "$@"
|
mocha -r ts-node/register ./test/*.test.ts "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,10 @@ interface Plugin extends pluginapi.Plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Application extends pluginapi.Application {
|
interface Application extends pluginapi.Application {
|
||||||
plugin: Plugin
|
/*
|
||||||
|
* Clone of the above without functions.
|
||||||
|
*/
|
||||||
|
plugin: Omit<Plugin, "init" | "router" | "applications">
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +60,15 @@ export class PluginAPI {
|
||||||
// Add plugin key to each app.
|
// Add plugin key to each app.
|
||||||
apps.push(
|
apps.push(
|
||||||
...pluginApps.map((app) => {
|
...pluginApps.map((app) => {
|
||||||
return { ...app, plugin: p }
|
return {
|
||||||
|
...app,
|
||||||
|
plugin: {
|
||||||
|
name: p.name,
|
||||||
|
version: p.version,
|
||||||
|
description: p.description,
|
||||||
|
modulePath: p.modulePath,
|
||||||
|
},
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -74,8 +85,8 @@ export class PluginAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* loadPlugins loads all plugins based on this.csPluginPath
|
* loadPlugins loads all plugins based on this.csPlugin,
|
||||||
* and this.csPlugin.
|
* this.csPluginPath and the built in plugins.
|
||||||
*/
|
*/
|
||||||
public async loadPlugins(): Promise<void> {
|
public async loadPlugins(): Promise<void> {
|
||||||
// Built-in plugins.
|
// Built-in plugins.
|
||||||
|
|
|
@ -12,8 +12,7 @@ describe("plugin", () => {
|
||||||
const papi = new PluginAPI(logger, path.resolve(__dirname, "test-plugin") + ":meow")
|
const papi = new PluginAPI(logger, path.resolve(__dirname, "test-plugin") + ":meow")
|
||||||
await papi.loadPlugins()
|
await papi.loadPlugins()
|
||||||
|
|
||||||
// We remove the function fields from the application's plugins.
|
const apps = await papi.applications()
|
||||||
const apps = JSON.parse(JSON.stringify(await papi.applications()))
|
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
[
|
[
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
out/index.js: src/index.ts
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
node_modules: package.json yarn.lock
|
||||||
|
yarn
|
Loading…
Reference in New Issue