Skip to content

Commit aa094f3

Browse files
fix(cli): render with no -o writes to the project's renders folder from any directory (#6766)
1 parent f7db6ba commit aa094f3

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/cli/src/commands/render/plan.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
22
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
33
import { tmpdir } from "node:os";
4-
import { basename, join, resolve } from "node:path";
4+
import { basename, dirname, join, parse, resolve } from "node:path";
55
import { CliUsageError } from "../../utils/commandResult.js";
66
import { createRenderPlan } from "./plan.js";
77

@@ -196,10 +196,17 @@ describe("createRenderPlan", () => {
196196
expect(plan.format).toBe("hls");
197197
expect(plan.hlsSegmentSeconds).toBe(4);
198198
// No extension: outputPath is the directory the playlists are written into.
199-
expect(plan.outputPath.startsWith(resolve("renders", plan.project.name))).toBe(true);
199+
expect(plan.outputPath.startsWith(join(projectDir, "renders", plan.project.name))).toBe(true);
200200
expect(basename(plan.outputPath)).not.toContain(".");
201201
});
202202

203+
it("writes the default output under the project's renders folder whatever the cwd is", () => {
204+
vi.spyOn(process, "cwd").mockReturnValue(parse(projectDir).root);
205+
const plan = createRenderPlan({ dir: projectDir });
206+
207+
expect(dirname(plan.outputPath)).toBe(join(projectDir, "renders"));
208+
});
209+
203210
it("carries an explicit --hls-segment-seconds and rejects a fractional one", () => {
204211
expect(
205212
createRenderPlan({ dir: projectDir, format: "hls", "hls-segment-seconds": "6" })

‎packages/cli/src/commands/render/plan.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ export function createRenderPlan(args: RenderCommandArgs, now = new Date()): Ren
457457
)
458458
: 1;
459459

460-
const rendersDir = resolve("renders");
460+
const rendersDir = join(project.dir, "renders");
461461
const ext = FORMAT_EXT[format];
462462
const timestamp = formatRenderOutputTimestamp(now);
463463
const batchOutputTemplate = args.output

0 commit comments

Comments
 (0)