From 1ece4fb325622ca723e593e9be48f7b97a9105cb Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Tue, 6 Feb 2018 14:50:30 -0800 Subject: [PATCH] fix: set pluginType --- src/command.ts | 2 ++ src/config.ts | 4 ++-- src/plugin.ts | 7 +++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/command.ts b/src/command.ts index 8fc4a411..16398462 100644 --- a/src/command.ts +++ b/src/command.ts @@ -12,6 +12,7 @@ export interface Command { examples?: string[] type?: string pluginName?: string + pluginType?: string flags: {[name: string]: Command.Flag} args: { name: string @@ -80,6 +81,7 @@ export namespace Command { description: c.description, usage: c.usage, pluginName: c.plugin && c.plugin.name, + pluginType: c.plugin && c.plugin.type, hidden: c.hidden, aliases: c.aliases || [], examples: c.examples, diff --git a/src/config.ts b/src/config.ts index 97abcaec..e37ced60 100644 --- a/src/config.ts +++ b/src/config.ts @@ -136,7 +136,7 @@ export class Config extends Plugin.Plugin implements IConfig { if (opts.devPlugins !== false) { try { const devPlugins = this.pjson.anycli.devPlugins - if (devPlugins) this.loadPlugins(this.root, devPlugins) + if (devPlugins) this.loadPlugins(this.root, 'dev', devPlugins) } catch (err) { process.emitWarning(err) } @@ -147,7 +147,7 @@ export class Config extends Plugin.Plugin implements IConfig { const userPJSONPath = path.join(this.dataDir, 'package.json') const pjson = this.userPJSON = loadJSONSync(userPJSONPath) if (!pjson.anycli) pjson.anycli = {schema: 1} - this.loadPlugins(userPJSONPath, pjson.anycli.plugins) + this.loadPlugins(userPJSONPath, 'user', pjson.anycli.plugins) } catch (err) { if (err.code !== 'ENOENT') process.emitWarning(err) } diff --git a/src/plugin.ts b/src/plugin.ts index 2eed3280..77bd6042 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -121,7 +121,7 @@ export class Plugin implements IPlugin { this.hooks = mapValues(this.pjson.anycli.hooks || {}, i => Array.isArray(i) ? i : [i]) this.manifest = this._manifest(!!opts.ignoreManifest) - this.loadPlugins(this.root, this.pjson.anycli.plugins || []) + this.loadPlugins(this.root, this.type, this.pjson.anycli.plugins || []) this.addMissingTopics() } @@ -304,18 +304,17 @@ export class Plugin implements IPlugin { } } - protected loadPlugins(root: string, plugins: (string | PJSON.Plugin)[]) { + protected loadPlugins(root: string, type: string, plugins: (string | PJSON.Plugin)[]) { if (!plugins.length) return if (!plugins || !plugins.length) return debug('loading plugins', plugins) for (let plugin of plugins || []) { try { - let opts: Options = {type: this.type, root} + let opts: Options = {type, root} if (typeof plugin === 'string') { opts.name = plugin } else { opts.name = plugin.name || opts.name - opts.type = plugin.type || opts.type opts.tag = plugin.tag || opts.tag opts.root = plugin.root || opts.root }