mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 16:08:56 +00:00
* fix(cli): staging folders beside a project path no longer fail past 260 characters on Windows mkdtemp does not get the long-path prefix that mkdir does, so every staging folder made beside a project or output path failed once its full path passed 260 characters. They now come from one helper, createStagingDir in @hyperframes/core/atomic-file, and a scan test fails on a new mkdtemp beside a path. * fix(cli): give mkdtemp the long-path form instead of replacing it CodeQL treats mkdtemp as the safe way to make a folder under the system temp dir and flagged every file written into a folder from the mkdir-based helper. createStagingDir now calls mkdtemp with the long-path form of the path on Windows, so both hold. * fix(cli): leave non-Windows paths alone when making a staging folder The long-path form is now chosen by the shape of the path, not process.platform, so tests that pretend to be Windows keep working and the comment share does not rise. * fix(core): a staging folder keeps a Windows path that already names its namespace * fix(core): a staging folder keeps a Windows device path as the caller gave it * fix(core): the staging folder helper's comment fits the line limit
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
// @vitest-environment node
|
|
import { describe, expect, it, vi } from "vitest";
|
|
import * as fs from "node:fs";
|
|
|
|
vi.mock(
|
|
"node:path",
|
|
async () => (await vi.importActual<typeof import("node:path")>("node:path")).win32,
|
|
);
|
|
vi.mock("node:fs", async (importOriginal) => ({
|
|
...(await importOriginal<typeof import("node:fs")>()),
|
|
mkdtempSync: vi.fn((prefix: string) => `${prefix}ABC123`),
|
|
}));
|
|
|
|
const { createStagingDir } = await import("./atomicFile");
|
|
|
|
describe("createStagingDir with Windows parents", () => {
|
|
it.each([
|
|
["a volume-GUID parent", "\\\\?\\Volume{11111111-1111-1111-1111-111111111111}\\project", ""],
|
|
["an already namespaced UNC parent", "\\\\?\\unc\\server\\share\\project", ""],
|
|
["a device drive parent", "\\\\.\\C:\\project", ""],
|
|
[
|
|
"a device volume-GUID parent",
|
|
"\\\\.\\Volume{11111111-1111-1111-1111-111111111111}\\project",
|
|
"",
|
|
],
|
|
["a drive parent", "C:\\project", "\\\\?\\C:\\project"],
|
|
["a UNC parent", "\\\\server\\share\\project", "\\\\?\\UNC\\server\\share\\project"],
|
|
])("returns the folder it made for %s", (_name, parent, longForm) => {
|
|
vi.mocked(fs.mkdtempSync).mockClear();
|
|
expect(createStagingDir(parent, ".stage-")).toBe(`${parent}\\.stage-ABC123`);
|
|
expect(vi.mocked(fs.mkdtempSync).mock.calls).toEqual([[`${longForm || parent}\\.stage-`]]);
|
|
});
|
|
});
|