diff --git a/packages/cli/src/browser/preflight.test.ts b/packages/cli/src/browser/preflight.test.ts index 0d1d56b40f..480e28f6fe 100644 --- a/packages/cli/src/browser/preflight.test.ts +++ b/packages/cli/src/browser/preflight.test.ts @@ -1,6 +1,6 @@ // fallow-ignore-file code-duplication import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; -import { parseToolVersion, runEnvironmentChecks } from "./preflight.js"; +import { checkDisk, parseToolVersion, runEnvironmentChecks } from "./preflight.js"; import * as manager from "./manager.js"; import * as linuxDeps from "./linuxDeps.js"; @@ -187,3 +187,15 @@ describe("parseToolVersion", () => { ); }); }); + +describe("checkDisk", () => { + it("checks the requested render volume", () => { + const freeDiskMb = vi.fn(() => 512); + + expect(checkDisk("/external/render-output", freeDiskMb)).toMatchObject({ + ok: false, + detail: "0.5 GB free at /external/render-output", + }); + expect(freeDiskMb).toHaveBeenCalledWith("/external/render-output"); + }); +}); diff --git a/packages/cli/src/browser/preflight.ts b/packages/cli/src/browser/preflight.ts index 712ae9c169..80e774471b 100644 --- a/packages/cli/src/browser/preflight.ts +++ b/packages/cli/src/browser/preflight.ts @@ -38,6 +38,7 @@ export interface EnvironmentCheckResult { export interface EnvironmentCheckOptions { projectDir?: string; + diskPaths?: string[]; browserPath?: string; includeBrowser?: boolean; includeDisk?: boolean; @@ -205,8 +206,11 @@ async function checkChrome(browserPath?: string): Promise number | null = getFreeDiskMb, +): EnvironmentCheckOutcome { + const freeMb = freeDiskMb(path); if (freeMb === null) { return { name: "Disk", ok: true, level: "ok", detail: "Unable to check" }; } @@ -217,11 +221,11 @@ function checkDisk(projectDir = "."): EnvironmentCheckOutcome { ok: false, level: "error", title: "Low disk space", - detail: `${freeGb} GB free`, + detail: `${freeGb} GB free at ${path}`, hint: "Renders produce large temp files. Free disk space before rendering.", }; } - return { name: "Disk", ok: true, level: "ok", detail: `${freeGb} GB free` }; + return { name: "Disk", ok: true, level: "ok", detail: `${freeGb} GB free at ${path}` }; } function checkWindowsUncPath(projectDir = process.cwd()): EnvironmentCheckOutcome | undefined { @@ -260,7 +264,8 @@ export async function runEnvironmentChecks( } if (options.includeDisk) { - outcomes.push(checkDisk(options.projectDir)); + const diskPaths = [...new Set(options.diskPaths ?? [options.projectDir ?? "."])]; + outcomes.push(...diskPaths.map((path) => checkDisk(path))); } if (options.includeWindowsUnc) { diff --git a/packages/cli/src/commands/render.ts b/packages/cli/src/commands/render.ts index 6c665035b1..f436267691 100644 --- a/packages/cli/src/commands/render.ts +++ b/packages/cli/src/commands/render.ts @@ -1423,6 +1423,7 @@ export async function renderLocal( ): Promise { const preflight = await runEnvironmentChecks({ projectDir, + diskPaths: [tmpdir(), dirname(outputPath)], browserPath: options.browserPath, includeBrowser: true, includeDisk: true,