Skip to content

Commit 5355203

Browse files
authored
feat: return results from runHook (#187)
* feat: return results from runHook * build: remove windows build for now
1 parent 857c8f3 commit 5355203

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ workflows:
1212
parameters:
1313
os:
1414
- linux
15-
- windows
15+
# - windows
1616
node_version:
1717
- latest
1818
- lts

src/config/config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,15 +205,14 @@ export class Config implements IConfig {
205205
}
206206
}
207207

208-
async runHook<T>(event: string, opts: T) {
208+
async runHook<T>(event: string, opts: T): Promise<any> {
209209
debug('start %s hook', event)
210-
211210
const search = (m: any): Hook<T> => {
212211
if (typeof m === 'function') return m
213212
if (m.default && typeof m.default === 'function') return m.default
214213
return Object.values(m).find((m: any) => typeof m === 'function') as Hook<T>
215214
}
216-
215+
const results = []
217216
for (const p of this.plugins) {
218217
const debug = require('debug')([this.bin, p.name, 'hooks', event].join(':'))
219218
const context: Hook.Context = {
@@ -242,8 +241,8 @@ export class Config implements IConfig {
242241

243242
debug('start', isESM ? '(import)' : '(require)', filePath)
244243

245-
await search(module).call(context, {...opts as any, config: this})
246-
/* eslint-enable no-await-in-loop */
244+
const result = await search(module).call(context, {...opts as any, config: this})
245+
results.push(result)
247246

248247
debug('done')
249248
} catch (error) {
@@ -254,6 +253,7 @@ export class Config implements IConfig {
254253
}
255254

256255
debug('%s hook done', event)
256+
return results
257257
}
258258

259259
async runCommand<T = unknown>(id: string, argv: string[] = [], cachedCommand?: Command.Plugin): Promise<T> {

src/interfaces/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export interface Config {
9595

9696
runCommand<T = unknown>(id: string, argv?: string[]): Promise<T>;
9797
runCommand<T = unknown>(id: string, argv?: string[], cachedCommand?: Command.Plugin): Promise<T>;
98-
runHook<T extends Hooks, K extends Extract<keyof T, string>>(event: K, opts: T[K]): Promise<void>;
98+
runHook<T extends Hooks, K extends Extract<keyof T, string>>(event: K, opts: T[K]): Promise<any>;
9999
findCommand(id: string, opts: { must: true }): Command.Plugin;
100100
findCommand(id: string, opts?: { must: boolean }): Command.Plugin | undefined;
101101
findTopic(id: string, opts: { must: true }): Topic;

0 commit comments

Comments
 (0)