Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/studio-api/helpers/safePath.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function createProjectDir(): string {
}

describe("walkDir", () => {
it("hides internal HyperFrames files from project listings", () => {
it("hides only internal HyperFrames backups, not vendored dot-directory files", () => {
const projectDir = createProjectDir();
mkdirSync(join(projectDir, ".hyperframes", "backup"), { recursive: true });
mkdirSync(join(projectDir, ".hyperframes", "examples"), { recursive: true });
Expand All @@ -31,9 +31,11 @@ describe("walkDir", () => {
writeFileSync(join(projectDir, "compositions", "scene.html"), "scene");

const files = walkDir(projectDir);
// Vendored dot-dir files stay browsable in the file tree (#1366) — only
// Studio's own backup snapshots are hidden (shouldIgnoreDir).
expect(files).toContain(".cache/examples/preset.html");
expect(files).toContain(".hyperframes/examples/preset.html");
expect(files).toContain("compositions/scene.html");
expect(files).not.toContain(".hyperframes/backup/snapshot.html");
expect(files).not.toContain(".hyperframes/examples/preset.html");
});
});
8 changes: 6 additions & 2 deletions packages/core/src/studio-api/helpers/safePath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import { readdirSync } from "node:fs";
// Re-exported here for back-compat with existing `../helpers/safePath.js` imports.
export { isSafePath } from "../../safePath.js";

const IGNORE_DIRS = new Set([".thumbnails", ".hyperframes", "node_modules", ".git"]);
const IGNORE_DIRS = new Set([".thumbnails", "node_modules", ".git"]);

function shouldIgnoreDir(rel: string): boolean {
return rel === ".hyperframes/backup";
}

/**
* True when any directory segment of a relative path is a dot-directory or
Expand All @@ -25,7 +29,7 @@ export function walkDir(dir: string, prefix = ""): string[] {
const files: string[] = [];
for (const entry of readdirSync(dir, { withFileTypes: true })) {
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
if (IGNORE_DIRS.has(entry.name)) continue;
if (IGNORE_DIRS.has(entry.name) || shouldIgnoreDir(rel)) continue;
if (entry.isDirectory()) {
files.push(...walkDir(join(dir, entry.name), rel));
} else {
Expand Down