Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(win): tell a directory from a file, and find Visual Studio where it is
Etienne Lescotf3902dceb6f3
diff --git a/scripts/before-pack.cjs b/scripts/before-pack.cjsindex f98cf702c..227d2d485 100644--- a/scripts/before-pack.cjs+++ b/scripts/before-pack.cjs@@ -343,8 +343,18 @@ function importedDlls(file) {* (crates/.cargo/config.toml).*/function checkWinNoRedistDependency(dir) {- const scanned = fs- .readdirSync(dir)+ // Regular files only, and the same list serves both questions below. A directory+ // answers `readdirSync` by name exactly as a file does, and this directory really+ // does hold subdirectories (the vendored ffmpeg SDK), so the distinction is not+ // hypothetical. Without it one named `something.dll` is opened as a binary and the+ // hook dies on a raw `EISDIR` — the build stops, which is right, on a message that+ // names nothing, which is not.+ const files = fs+ .readdirSync(dir, { withFileTypes: true })+ .filter((entry) => entry.isFile())+ .map((entry) => entry.name);++ const scanned = files.filter((name) => /\.(exe|dll|node)$/i.test(name)).map((name) => ({ name, imports: importedDlls(path.join(dir, name)) }));@@ -369,7 +379,7 @@ function checkWinNoRedistDependency(dir) {// a .node, the module's — the same colocation that carries the ffmpeg DLLs. Shipping// vcomp140.dll beside the ggml libraries is therefore a fix, not an exception, and// the check has to be able to say so or it would forbid the remedy it asks for.- const shipped = new Set(fs.readdirSync(dir).map((name) => name.toLowerCase()));+ const shipped = new Set(files.map((name) => name.toLowerCase()));const offenders = scanned.map((entry) => ({name: entry.name,diff --git a/scripts/stage-vcomp-runtime.mjs b/scripts/stage-vcomp-runtime.mjsindex f5071e0c5..06b35d6cf 100644--- a/scripts/stage-vcomp-runtime.mjs+++ b/scripts/stage-vcomp-runtime.mjs@@ -22,6 +22,7 @@import fs from "node:fs";import path from "node:path";import { fileURLToPath } from "node:url";+import { findVcVarsAll } from "./msvcEnv.mjs";const __dirname = path.dirname(fileURLToPath(import.meta.url));const ROOT = path.join(__dirname, "..");@@ -41,13 +42,30 @@ if (process.platform !== "win32") {* hard-coding it, and takes the newest it finds. The redistributable copy is used* in preference to the one in System32 because that is the copy Microsoft licenses* for redistribution with an application.+ *+ * Discovery reuses `findVcVarsAll`, the same lookup the two native build scripts+ * already run, so a Visual Studio installed anywhere is found here as well: it+ * consults VCVARSALL, then vswhere, then VSINSTALLDIR, then sweeps for the+ * pre-release channels vswhere does not enumerate. vcvarsall.bat sits at+ * `<root>\VC\Auxiliary\Build\`, hence the three levels up.+ *+ * That root is searched alone when it yields anything, which both prefers the+ * toolchain that actually compiled the helpers and avoids re-walking the same+ * subtree — the installation usually lives under the fixed paths below, and those+ * trees are large enough that scanning one twice is worth avoiding.*/-function findRedistCopies() {- const roots = [+function searchRoots() {+ const vcvarsall = findVcVarsAll();+ if (vcvarsall) {+ return [path.resolve(path.dirname(vcvarsall), "..", "..", "..")];+ }+ return ["C:\\Program Files\\Microsoft Visual Studio","C:\\Program Files (x86)\\Microsoft Visual Studio",- ].filter((dir) => fs.existsSync(dir));+ ];+}+function findRedistCopies() {const found = [];const walk = (dir, depth) => {if (depth > 8) return;@@ -72,7 +90,7 @@ function findRedistCopies() {}}};- for (const root of roots) walk(root, 0);+ for (const root of searchRoots()) walk(root, 0);return found;}