@eljs/pluggable
Make pluggable easily.
Installation
$ pnpm add @eljs/pluggable
// or
$ yarn add @eljs/pluggable
// ro
$ npm i @eljs/pluggable -S
Usage
import { Pluggable } from '@eljs/pluggable'
export class Runner extends Pluggable {
public constructor(options: Config) {
super(options)
}
public async run() {
await this.load()
await this.applyPlugins('')
}
}
new Runner({
cwd: 'path/to/working/directory',
presets: [],
plugins: [],
}).run()
API
PluggablePluginApi
export interface PluggablePluginApi {
cwd: typeof Pluggable.prototype.cwd
applyPlugins: typeof Pluggable.prototype.applyPlugins
registerPresets: (presets: PluginDeclaration[]) => void
registerPlugins: (plugins: PluginDeclaration[]) => void
}
PluginApi
export interface PluginApi {
describe: (options: { key?: string; enable?: Enable }) => void
register: (
key: HookOptions['key'],
fn: HookOptions['fn'],
options: Omit<HookOptions, 'plugin' | 'key' | 'fn'>,
) => void
registerMethod: (name: string, fn?: MaybePromiseFunction<any>) => void
skipPlugins: (keys: string[]) => void
}