-
Notifications
You must be signed in to change notification settings - Fork 22
/
link.ts
42 lines (33 loc) · 1.46 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
34
35
36
37
38
39
40
41
42
import {Args, Command, Flags, ux} from '@oclif/core'
import {cyan} from 'ansis'
import {determineLogLevel} from '../../log-level.js'
import Plugins from '../../plugins.js'
export default class PluginsLink extends Command {
static args = {
path: Args.string({default: '.', description: 'path to plugin', name: 'path', required: true}),
}
static description = `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 examples = ['<%= config.bin %> <%= command.id %> <%- config.pjson.oclif.examplePlugin || "myplugin" %> ']
static flags = {
help: Flags.help({char: 'h'}),
install: Flags.boolean({
allowNo: true,
default: true,
description: 'Install dependencies after linking the plugin.',
}),
verbose: Flags.boolean({char: 'v'}),
}
static summary = 'Links a plugin into the CLI for development.'
async run(): Promise<void> {
const {args, flags} = await this.parse(PluginsLink)
const plugins = new Plugins({
config: this.config,
logLevel: determineLogLevel(this.config, flags, 'silent'),
})
ux.action.start(`${this.config.name}: Linking plugin ${cyan(args.path)}`)
await plugins.link(args.path, {install: flags.install})
ux.action.stop()
}
}