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

Commit

Permalink
fix: add missing topics
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 6, 2018
1 parent ecc00d5 commit 7aed261
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
"bugs": "https://github.com/anycli/config/issues",
"dependencies": {},
"devDependencies": {
"@anycli/errors": "^0.2.0",
"@anycli/parser": "^3.2.5",
"@anycli/tslint": "^0.2.6",
"@anycli/errors": "^0.2.1",
"@anycli/parser": "^3.2.6",
"@anycli/tslint": "^0.2.7",
"@types/chai": "^4.1.2",
"@types/globby": "^6.1.0",
"@types/indent-string": "^3.0.0",
"@types/mocha": "^2.2.48",
"@types/node": "^9.4.0",
"@types/node": "^9.4.1",
"@types/wrap-ansi": "^2.0.14",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
Expand Down
17 changes: 17 additions & 0 deletions src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class Plugin implements IPlugin {

this.manifest = this._manifest(!!opts.ignoreManifest)
this.loadPlugins(this.root, this.pjson.anycli.plugins || [])
this.addMissingTopics()
}

get commandsDir() {
Expand All @@ -131,6 +132,13 @@ export class Plugin implements IPlugin {
get topics() {
let topics = [...this._topics]
for (let plugin of this.plugins) {
for (let topic of plugin.topics) {
let existing = topics.find(t => t.name === t.name)
if (existing) {
existing.description = topic.description || existing.description
existing.hidden = topic.hidden === undefined ? existing.hidden : topic.hidden
} else topics.push(topic)
}
topics = [...topics, ...plugin.topics]
}
return topics
Expand Down Expand Up @@ -323,6 +331,15 @@ export class Plugin implements IPlugin {
err.detail = compact([err.detail, `module: ${this._base}`, scope && `task: ${scope}`, `plugin: ${this.name}`, `root: ${this.root}`]).join('\n')
process.emitWarning(err)
}

protected addMissingTopics() {
for (let c of this.commands.filter(c => !c.hidden)) {
let name = c.id.split(':').slice(0, -1).join(':')
if (name && !this._topics.find(t => t.name === name)) {
this._topics.push({name})
}
}
}
}

function topicsToArray(input: any, base?: string): Topic[] {
Expand Down
24 changes: 14 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# yarn lockfile v1


"@anycli/errors@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@anycli/errors/-/errors-0.2.0.tgz#ee421115dcdb499d76de9d4853718c06e1c5d5f0"
"@anycli/errors@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@anycli/errors/-/errors-0.2.1.tgz#719a95cd9c23838c65929da5d625a7537dd7d035"
dependencies:
clean-stack "^1.3.0"
fs-extra "^5.0.0"
indent-string "^3.2.0"
strip-ansi "^4.0.0"
wrap-ansi "^3.0.1"

"@anycli/parser@^3.2.5":
version "3.2.5"
resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.2.5.tgz#d0e7ddb14945cb84377fa69095009ca6005e6b6d"
"@anycli/parser@^3.2.6":
version "3.2.6"
resolved "https://registry.yarnpkg.com/@anycli/parser/-/parser-3.2.6.tgz#bbd119a80709099179a9f11af0dc44b68c54575b"

"@anycli/tslint@^0.2.6":
version "0.2.6"
resolved "https://registry.yarnpkg.com/@anycli/tslint/-/tslint-0.2.6.tgz#4251f4cb3744dc577309b4351d2c2e8b65072de2"
"@anycli/tslint@^0.2.7":
version "0.2.7"
resolved "https://registry.yarnpkg.com/@anycli/tslint/-/tslint-0.2.7.tgz#68b81121f33e9aa8240bd12cfade1f6023e6820d"
dependencies:
tslint "^5.9.1"
tslint-xo "^0.6.0"
Expand Down Expand Up @@ -57,10 +57,14 @@
version "2.2.48"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab"

"@types/node@*", "@types/node@^9.4.0":
"@types/node@*":
version "9.4.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1"

"@types/node@^9.4.1":
version "9.4.1"
resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.1.tgz#0f636f7837e15d2d73a7f6f3ea0e322eb2a5ab65"

"@types/strip-bom@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2"
Expand Down

0 comments on commit 7aed261

Please sign in to comment.