GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode/packages/desktop/script/verify-bundles.ts at dev · erickwill/opencode

Expand file tree

/

verify-bundles.ts

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
51 lines (38 loc) · 1.64 KB
/

verify-bundles.ts

Copy path

File metadata and controls

51 lines (38 loc) · 1.64 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import path from "node:path"
import { Script, SourceTextModule } from "node:vm"
const targets = ["main", "preload"] as const
// Parses every built main and preload bundle without executing it, catching syntax and early
// redeclaration errors even in chunks that the app loads lazily at runtime.
export async function verifyBundles(outDir: string) {
const glob = new Bun.Glob("**/*.{js,cjs,mjs}")
const failures: string[] = []
for (const target of targets) {
const dir = path.join(outDir, target)
const files = await Array.fromAsync(glob.scan({ cwd: dir, onlyFiles: true })).catch(() => [])
if (files.length === 0) throw new Error(`Expected built chunks in ${dir}, found none`)
const errors = await Promise.all(
files.sort().map(async (file) => {
const label = `${target}/${file.replaceAll("\\", "/")}`
const error = parseError(await Bun.file(path.join(dir, file)).text(), label)
return error ? `${label}: ${error}` : undefined
}),
)
failures.push(...errors.filter((item): item is string => item !== undefined))
}
if (failures.length > 0) throw new Error(`Desktop bundle syntax check failed:\n${failures.join("\n")}`)
}
function parseError(code: string, identifier: string) {
const source = code.replace(/^#!.*\r?\n/, "\n")
try {
if (identifier.endsWith(".cjs")) {
new Script(`(function (exports, require, module, __filename, __dirname) { ${source}\n})`, {
filename: identifier,
})
return undefined
}
new SourceTextModule(source, { identifier })
return undefined
} catch (error) {
return error instanceof Error ? error.message : String(error)
}
}
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.