From f23e8d126e5103dd567ae1fa4c8b47b6a604080b Mon Sep 17 00:00:00 2001 From: Kara Brightwell Date: Fri, 8 Nov 2024 10:06:11 +0000 Subject: [PATCH] feat: pass task cwd through via TaskRunContext --- core/cli/src/tasks.ts | 9 +++++++-- lib/base/src/task.ts | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/cli/src/tasks.ts b/core/cli/src/tasks.ts index 7193547df..6bf5f2b9b 100644 --- a/core/cli/src/tasks.ts +++ b/core/cli/src/tasks.ts @@ -56,7 +56,12 @@ const loadTasks = async ( return reduceValidated(taskResults) } -export async function runTasksFromConfig(logger: Logger, config: ValidConfig, commands: string[], files?: string[]): Promise { +export async function runTasksFromConfig( + logger: Logger, + config: ValidConfig, + commands: string[], + files?: string[] +): Promise { for (const pluginOptions of Object.values(config.pluginOptions)) { if (pluginOptions.forPlugin) { setOptions(pluginOptions.forPlugin.id as OptionKey, pluginOptions.options) @@ -91,7 +96,7 @@ export async function runTasksFromConfig(logger: Logger, config: ValidConfig, co for (const task of tasks) { try { logger.info(styles.taskHeader(`running ${styles.task(task.id)} task`)) - await task.run({ files, command }) + await task.run({ files, command, cwd: config.root }) } catch (error) { // if there's an exit code, that's a request from the task to exit early if (error instanceof ToolKitError && error.exitCode) { diff --git a/lib/base/src/task.ts b/lib/base/src/task.ts index 45117b928..320df44ee 100644 --- a/lib/base/src/task.ts +++ b/lib/base/src/task.ts @@ -8,6 +8,7 @@ type Default = T extends undefined ? D : T export type TaskRunContext = { files?: string[] command: string + cwd: string } export abstract class Task<