Skip to content

Commit

Permalink
fix: pass task cwd through via TaskRunContext
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost committed Nov 4, 2024
1 parent f7f2872 commit d2b5026
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/cli/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,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
3 changes: 1 addition & 2 deletions plugins/monorepo/src/tasks/workspace-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ export default class WorkspaceCommand extends Task<{ task: typeof WorkspaceComma
return runTasksFromConfig(this.logger.child({ packageId }), config, [command], files)
}

async run({ command, files }: TaskRunContext) {
const cwd = process.cwd()
async run({ command, files, cwd }: TaskRunContext) {
const pkg = JSON.parse(await fs.readFile(path.join(cwd, 'package.json'), 'utf8'))

const workspaces = await mapWorkspaces({ cwd, pkg })
Expand Down

0 comments on commit d2b5026

Please sign in to comment.