Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: make topics a getter
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 7, 2018
1 parent 3d3bd38 commit cc3e775
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface IPlugin {
commands: Command.Plugin[]
hooks: {[k: string]: string[]}
readonly commandIDs: string[]
topics: Topic[]
readonly topics: Topic[]

findCommand(id: string, opts: {must: true}): Command.Class
findCommand(id: string, opts?: {must: boolean}): Command.Class | undefined
Expand All @@ -82,7 +82,6 @@ export class Plugin implements IPlugin {
root: string
tag?: string
manifest: Manifest
topics: Topic[]
commands: Command.Plugin[]
hooks: {[k: string]: string[]}
valid = false
Expand Down Expand Up @@ -110,14 +109,15 @@ export class Plugin implements IPlugin {
this.pjson.anycli = this.pjson['cli-engine'] || {}
}

this.topics = topicsToArray(this.pjson.anycli.topics || {})
this.hooks = mapValues(this.pjson.anycli.hooks || {}, i => Array.isArray(i) ? i : [i])

this.manifest = this._manifest(!!opts.ignoreManifest)
this.commands = Object.entries(this.manifest.commands)
.map(([id, c]) => ({...c, load: () => this.findCommand(id, {must: true})}))
}

get topics(): Topic[] { return topicsToArray(this.pjson.anycli.topics || {}) }

get commandsDir() { return tsPath(this.root, this.pjson.anycli.commands) }
get commandIDs() {
if (!this.commandsDir) return []
Expand Down

0 comments on commit cc3e775

Please sign in to comment.