Skip to content

armgit / hypit

Public Imported from GitHub
0

Clone any viral video with AI agents. Not just a script, the whole workflow: swap the face, the words, the B-roll, ship 100 variants in one command, and get your 100M views.

fix: a file name is the last segment, not whatever follows a slash

rpone35ea4e9bb504
diff --git a/packages/fonts-open/src/surface.ts b/packages/fonts-open/src/surface.ts
index 253f0ee0..5c6d9126 100644
--- a/packages/fonts-open/src/surface.ts
+++ b/packages/fonts-open/src/surface.ts
@@ -1,6 +1,7 @@
import { readFileSync } from "node:fs";
import { readFile } from "node:fs/promises";
import { createRequire } from "node:module";
+import { basename as fileName } from "node:path";
import {
assertFontArtifactRef,
@@ -112,7 +113,11 @@ async function materializeFace(
: [{ path: oneFile(request.family, request.weight, request.style) }];
const resolvedSources: FontArtifactRef["sources"] = await Promise.all(files.map(async (file) => {
const bytes = Uint8Array.from(await readFile(file.path));
- const basename = file.path.split("/").at(-1)!;
+ // `require.resolve` answers in the platform's own separator, and this name goes into the
+ // asset's provenance. Splitting on "/" left the whole absolute path standing in for the file
+ // name wherever that separator is a backslash, which put a machine's directory layout inside
+ // an identity that is supposed to name a font file and nothing else.
+ const basename = fileName(file.path);
const resolved = await resolveAsset({
from: `package:@hypit/fonts-open/${request.familyName}/${basename}`,
mediaType: "font/woff2",
diff --git a/packages/workspace-fs-node/src/workspace.ts b/packages/workspace-fs-node/src/workspace.ts
index 08089021..264ef10c 100644
--- a/packages/workspace-fs-node/src/workspace.ts
+++ b/packages/workspace-fs-node/src/workspace.ts
@@ -1,7 +1,7 @@
import { createHash } from "node:crypto";
import { createReadStream } from "node:fs";
import { readFile, realpath } from "node:fs/promises";
-import { dirname, isAbsolute, relative, resolve } from "node:path";
+import { basename, dirname, isAbsolute, relative, resolve } from "node:path";
import type {
SourceAssetRequest,
@@ -53,7 +53,7 @@ class NodeFilesystemWorkspaceSession implements WorkspaceSession {
}
const entry: SourceUnit = {
id: canonicalEntry,
- name: relative(root, canonicalEntry) || canonicalEntry.split("/").at(-1) || canonicalEntry,
+ name: relative(root, canonicalEntry) || basename(canonicalEntry) || canonicalEntry,
text: await readFile(canonicalEntry, "utf8"),
};
return new NodeFilesystemWorkspaceSession(root, entry, [root, ...assetRoots]);
@@ -72,7 +72,7 @@ class NodeFilesystemWorkspaceSession implements WorkspaceSession {
if (cached !== undefined) return cached;
const unit: SourceUnit = {
id: canonical,
- name: relative(this.root, canonical) || canonical.split("/").at(-1) || canonical,
+ name: relative(this.root, canonical) || basename(canonical) || canonical,
text: await readFile(canonical, "utf8"),
};
this.#sourceCache.set(canonical, unit);