Skip to content

Commit

Permalink
feat: pass task cwd through via TaskRunContext
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost committed Nov 11, 2024
1 parent 0591035 commit f23e8d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
9 changes: 7 additions & 2 deletions core/cli/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ const loadTasks = async (
return reduceValidated(taskResults)
}

export async function runTasksFromConfig(logger: Logger, config: ValidConfig, commands: string[], files?: string[]): Promise<void> {
export async function runTasksFromConfig(
logger: Logger,
config: ValidConfig,
commands: string[],
files?: string[]
): Promise<void> {
for (const pluginOptions of Object.values(config.pluginOptions)) {
if (pluginOptions.forPlugin) {
setOptions(pluginOptions.forPlugin.id as OptionKey, pluginOptions.options)
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions lib/base/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Default<T, D> = T extends undefined ? D : T
export type TaskRunContext = {
files?: string[]
command: string
cwd: string
}

export abstract class Task<
Expand Down

0 comments on commit f23e8d1

Please sign in to comment.