-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathlink.ts
33 lines (24 loc) · 1.18 KB
/
link.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import {Command, Flags, CliUx} from '@oclif/core'
import * as chalk from 'chalk'
import Plugins from '../../plugins'
export default class PluginsLink extends Command {
static description = `Links a plugin into the CLI for development.
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello' command will override the user-installed or core plugin implementation. This is useful for development work.
`
static usage = 'plugins:link PLUGIN'
static examples = ['$ <%= config.bin %> plugins:link <%- config.pjson.oclif.examplePlugin || "myplugin" %> ']
static args = [{name: 'path', description: 'path to plugin', required: true, default: '.'}]
static flags = {
help: Flags.help({char: 'h'}),
verbose: Flags.boolean({char: 'v'}),
}
plugins = new Plugins(this.config)
async run(): Promise<void> {
const {flags, args} = await this.parse(PluginsLink)
this.plugins.verbose = flags.verbose
CliUx.ux.action.start(`Linking plugin ${chalk.cyan(args.path)}`)
await this.plugins.link(args.path)
CliUx.ux.action.stop()
}
}