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

Commit

Permalink
fix: add options to convertToCached
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Jan 28, 2018
1 parent c3284b0 commit e47a6be
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"tslib": "^1.9.0"
},
"devDependencies": {
"@dxcli/config": "^0.1.29",
"@dxcli/dev": "^2.0.14",
"@dxcli/config": "^0.1.32",
"@dxcli/dev": "^2.0.15",
"@dxcli/dev-semantic-release": "^0.2.0",
"@dxcli/semantic-release": "^0.3.3",
"@dxcli/tslint": "^0.1.2",
"@dxcli/tslint": "^0.1.3",
"chai": "^4.1.2",
"cli-ux": "^3.3.8",
"eslint": "^4.16.0",
Expand Down
25 changes: 10 additions & 15 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,18 @@ const g = global as any

const parentModule = module.parent && module.parent.parent && module.parent.parent.filename

export function convertToCached(c: Config.ICommand): Config.ICachedCommand {
let plugin
if (c.plugin) {
plugin = {
name: c.plugin.name,
version: c.plugin.version,
type: c.plugin.type,
tag: c.plugin.tag,
root: c.plugin.root,
}
}
export interface ConvertToCachedOptions {
id?: string
plugin?: Config.IPlugin
}

export function convertToCached(c: Config.ICommand, opts: ConvertToCachedOptions = {}): Config.ICachedCommand {
return {
_base: c._base,
id: c.id,
id: c.id || opts.id!,
description: c.description,
usage: c.usage,
plugin,
pluginName: opts.plugin && opts.plugin.name,
hidden: c.hidden,
aliases: c.aliases || [],
help: c.help,
Expand Down Expand Up @@ -64,8 +59,8 @@ export default abstract class Command {
}
static async load() { return this }

static convertToCached(): Config.ICachedCommand {
return convertToCached(this)
static convertToCached(opts: ConvertToCachedOptions = {}): Config.ICachedCommand {
return convertToCached(this, opts)
}

config: Config.IConfig
Expand Down
19 changes: 10 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,11 @@
dependencies:
find-up "^2.1.0"

"@dxcli/config@^0.1.29":
version "0.1.29"
resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.29.tgz#33aca8d9af141af84da15d22f67fb642459466cb"
"@dxcli/config@^0.1.32":
version "0.1.32"
resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.32.tgz#b07b33cc9f91031ff795983bacf8a84f60294ecb"
dependencies:
cli-ux "^3.3.8"
debug "^3.1.0"
fs-extra "^5.0.0"
load-json-file "^4.0.0"
Expand Down Expand Up @@ -138,9 +139,9 @@
semantic-release "^12.2.5"
shelljs "^0.8.1"

"@dxcli/dev@^2.0.14":
version "2.0.14"
resolved "https://registry.yarnpkg.com/@dxcli/dev/-/dev-2.0.14.tgz#44834aa54dc60a11737e583a1716405207ab81a2"
"@dxcli/dev@^2.0.15":
version "2.0.15"
resolved "https://registry.yarnpkg.com/@dxcli/dev/-/dev-2.0.15.tgz#2984dabb5e8069515ed328cb59d920a00bee7483"
dependencies:
"@dxcli/nyc-config" "^0.0.4"
"@types/ansi-styles" "^2.0.30"
Expand Down Expand Up @@ -186,9 +187,9 @@
execa "^0.9.0"
semantic-release "^12.2.5"

"@dxcli/tslint@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@dxcli/tslint/-/tslint-0.1.2.tgz#943c36b2faef36a3ca2eed760267da0c859c89b3"
"@dxcli/tslint@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@dxcli/tslint/-/tslint-0.1.3.tgz#9a7334bab9fd442e8de3d8dcbec8cc1d8d13333e"
dependencies:
tslint "^5.9.1"
tslint-xo "^0.5.0"
Expand Down

0 comments on commit e47a6be

Please sign in to comment.