@oclif/core
Advanced tools
Comparing version 3.25.3 to 3.26.0
@@ -246,3 +246,10 @@ "use strict"; | ||
}; | ||
const results = await Parser.parse(argv, opts); | ||
const hookResult = await this.config.runHook('preparse', { argv: [...argv], options: opts }); | ||
// Since config.runHook will only run the hook for the root plugin, hookResult.successes will always have a length of 0 or 1 | ||
// But to be extra safe, we find the result that matches the root plugin. | ||
const argvToParse = hookResult.successes?.length | ||
? hookResult.successes.find((s) => s.plugin.root === cache_1.default.getInstance().get('rootPlugin')?.root)?.result ?? argv | ||
: argv; | ||
this.argv = [...argvToParse]; | ||
const results = await Parser.parse(argvToParse, opts); | ||
this.warnIfFlagDeprecated(results.flags ?? {}); | ||
@@ -249,0 +256,0 @@ return results; |
@@ -53,2 +53,3 @@ "use strict"; | ||
const BASE = `${_pjson.name}@${_pjson.version}`; | ||
const ROOT_ONLY_HOOKS = new Set(['preparse']); | ||
function channelFromVersion(version) { | ||
@@ -472,3 +473,4 @@ const m = version.match(/[^-]+(?:-([^.]+))?/); | ||
}; | ||
const promises = [...this.plugins.values()].map(async (p) => { | ||
const plugins = ROOT_ONLY_HOOKS.has(event) ? [this.rootPlugin] : [...this.plugins.values()]; | ||
const promises = plugins.map(async (p) => { | ||
const debug = require('debug')([this.bin, p.name, 'hooks', event].join(':')); | ||
@@ -475,0 +477,0 @@ const context = { |
import { Command } from '../command'; | ||
import { Config } from './config'; | ||
import { Input, OutputFlags } from './parser'; | ||
import { Plugin } from './plugin'; | ||
@@ -73,2 +74,9 @@ interface HookMeta { | ||
}; | ||
preparse: { | ||
options: { | ||
argv: string[]; | ||
options: Input<OutputFlags<any>, OutputFlags<any>, OutputFlags<any>>; | ||
}; | ||
return: string[]; | ||
}; | ||
prerun: { | ||
@@ -75,0 +83,0 @@ options: { |
{ | ||
"name": "@oclif/core", | ||
"description": "base library for oclif CLIs", | ||
"version": "3.25.3", | ||
"version": "3.26.0", | ||
"author": "Salesforce", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues", |
445496
11506