diff --git a/packages/cli/src/commands/render/plan.test.ts b/packages/cli/src/commands/render/plan.test.ts index e73915fb1b..89cbd2b8cb 100644 --- a/packages/cli/src/commands/render/plan.test.ts +++ b/packages/cli/src/commands/render/plan.test.ts @@ -1,7 +1,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; -import { basename, join, resolve } from "node:path"; +import { basename, dirname, join, parse, resolve } from "node:path"; import { CliUsageError } from "../../utils/commandResult.js"; import { createRenderPlan } from "./plan.js"; @@ -196,10 +196,17 @@ describe("createRenderPlan", () => { expect(plan.format).toBe("hls"); expect(plan.hlsSegmentSeconds).toBe(4); // No extension: outputPath is the directory the playlists are written into. - expect(plan.outputPath.startsWith(resolve("renders", plan.project.name))).toBe(true); + expect(plan.outputPath.startsWith(join(projectDir, "renders", plan.project.name))).toBe(true); expect(basename(plan.outputPath)).not.toContain("."); }); + it("writes the default output under the project's renders folder whatever the cwd is", () => { + vi.spyOn(process, "cwd").mockReturnValue(parse(projectDir).root); + const plan = createRenderPlan({ dir: projectDir }); + + expect(dirname(plan.outputPath)).toBe(join(projectDir, "renders")); + }); + it("carries an explicit --hls-segment-seconds and rejects a fractional one", () => { expect( createRenderPlan({ dir: projectDir, format: "hls", "hls-segment-seconds": "6" }) diff --git a/packages/cli/src/commands/render/plan.ts b/packages/cli/src/commands/render/plan.ts index 8c11cd4778..2df7d830d1 100644 --- a/packages/cli/src/commands/render/plan.ts +++ b/packages/cli/src/commands/render/plan.ts @@ -457,7 +457,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren ) : 1; - const rendersDir = resolve("renders"); + const rendersDir = join(project.dir, "renders"); const ext = FORMAT_EXT[format]; const timestamp = formatRenderOutputTimestamp(now); const batchOutputTemplate = args.output