@oclif/core 2.8.6 → 2.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,6 +135,15 @@ export declare class Config implements IConfig {
135
135
  * @returns command instance {Command.Loadable} or undefined
136
136
  */
137
137
  private determinePriority;
138
+ /**
139
+ * Insert legacy plugins
140
+ *
141
+ * Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
142
+ * with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
143
+ *
144
+ * @param plugins array of oclif-compatible plugins
145
+ * @returns void
146
+ */
138
147
  private insertLegacyPlugins;
139
148
  }
140
149
  export declare function toCached(c: Command.Class, plugin?: IPlugin | undefined, isWritingManifest?: boolean): Promise<Command.Cached>;
@@ -703,11 +703,23 @@ class Config {
703
703
  });
704
704
  return commandPlugins[0];
705
705
  }
706
+ /**
707
+ * Insert legacy plugins
708
+ *
709
+ * Replace invalid CLI plugins (cli-engine plugins, mostly Heroku) loaded via `this.loadPlugins`
710
+ * with oclif-compatible ones returned by @oclif/plugin-legacy init hook.
711
+ *
712
+ * @param plugins array of oclif-compatible plugins
713
+ * @returns void
714
+ */
706
715
  insertLegacyPlugins(plugins) {
707
716
  for (const plugin of plugins) {
708
717
  const idx = this.plugins.findIndex(p => p.name === plugin.name);
709
- if (idx !== -1)
710
- this.plugins = this.plugins.splice(idx, 1, plugin);
718
+ if (idx !== -1) {
719
+ // invalid plugin instance found in `this.plugins`
720
+ // replace with the oclif-compatible one
721
+ this.plugins.splice(idx, 1, plugin);
722
+ }
711
723
  this.loadCommands(plugin);
712
724
  }
713
725
  }
@@ -85,7 +85,7 @@ class Parser {
85
85
  if (this.flagAliases[char]) {
86
86
  return this.flagAliases[char].name;
87
87
  }
88
- return Object.keys(this.input.flags).find(k => this.input.flags[k].char === char);
88
+ return Object.keys(this.input.flags).find(k => (this.input.flags[k].char === char && char !== undefined && this.input.flags[k].char !== undefined));
89
89
  };
90
90
  const parseFlag = (arg) => {
91
91
  const long = arg.startsWith('--');
@@ -106,11 +106,12 @@ class Parser {
106
106
  const flag = this.input.flags[name];
107
107
  if (flag.type === 'option') {
108
108
  this.currentFlag = flag;
109
- const input = long || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2);
110
- if (typeof input !== 'string') {
109
+ const value = long || arg.length < 3 ? this.argv.shift() : arg.slice(arg[2] === '=' ? 3 : 2);
110
+ // if the value ends up being one of the command's flags, the user didn't provide an input
111
+ if (typeof value !== 'string' || this.input.flags[findLongFlag(value)] || this.input.flags[findShortFlag(value)]) {
111
112
  throw new errors_1.CLIError(`Flag --${name} expects a value`);
112
113
  }
113
- this.raw.push({ type: 'flag', flag: flag.name, input });
114
+ this.raw.push({ type: 'flag', flag: flag.name, input: value });
114
115
  }
115
116
  else {
116
117
  this.raw.push({ type: 'flag', flag: flag.name, input: arg });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "2.8.6",
4
+ "version": "2.8.8",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {