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

Commit

Permalink
fix: uniq commandIDs
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Feb 6, 2018
1 parent 5322a80 commit b145673
Show file tree
Hide file tree
Showing 2 changed files with 7 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 @@ -11,7 +11,7 @@ import {Manifest} from './manifest'
import {PJSON} from './pjson'
import {Topic} from './topic'
import {tsPath} from './ts_node'
import {compact, flatMap, loadJSONSync, mapValues} from './util'
import {compact, flatMap, loadJSONSync, mapValues, uniq} from './util'

export interface Options {
root: string
Expand Down Expand Up @@ -107,7 +107,7 @@ export class Plugin implements IPlugin {
}
Plugin.loadedPlugins[root] = this
this.root = root
debug('reading plugin %s', root)
debug('reading %s plugin %s', this.type, root)
this.pjson = loadJSONSync(path.join(root, 'package.json')) as any
this.name = this.pjson.name
this.version = this.pjson.version
Expand Down Expand Up @@ -158,7 +158,7 @@ export class Plugin implements IPlugin {
for (let plugin of this.plugins) {
commands = [...commands, ...plugin.commandIDs]
}
return commands
return uniq(commands)
}

findCommand(id: string, opts: {must: true}): Command.Plugin
Expand Down
4 changes: 4 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@ export function loadJSONSync(path: string): any {
export function compact<T>(a: (T | undefined)[]): T[] {
return a.filter((a): a is T => !!a)
}

export function uniq<T>(arr: T[]): T[] {
return arr.filter(a => arr.includes(a))
}

0 comments on commit b145673

Please sign in to comment.