Skip to content

Commit 6e69945

Browse files
prefer dash for binary options (#14)
* prefer dash for binary options * chore: upgrade node 22 * fix: typecheck --------- Co-authored-by: Nicolas Rigaudiere <i.am.a@curious.engineer>
1 parent ce25927 commit 6e69945

5 files changed

Lines changed: 25 additions & 11 deletions

File tree

packages/browser/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
"url": "https://github.com/lightpanda-io/node-packages/issues"
3636
},
3737
"homepage": "https://github.com/lightpanda-io/node-packages/tree/main/packages/browser#readme",
38+
"engines": {
39+
"node": "22.16",
40+
"yarn": "4.9"
41+
},
3842
"devDependencies": {
3943
"@biomejs/biome": "^1.9.4",
4044
"@types/node": "22.15.32",
@@ -46,4 +50,4 @@
4650
"dependencies": {
4751
"yargs": "^18.0.0"
4852
}
49-
}
53+
}

packages/browser/src/download.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,19 @@ const PLATFORMS = {
3939
arm64: 'aarch64-linux',
4040
},
4141
}
42+
const CURRENT_PLATFORM = platform as 'darwin' | 'linux'
43+
const CURRENT_ARCH = arch as 'arm64' | 'x64'
4244

4345
/**
4446
* Download Lightpanda's binary
4547
* @returns {Promise<void>}
4648
*/
4749
export const download = async (): Promise<void> => {
48-
const platformPath = PLATFORMS?.[platform]?.[arch]
50+
if (!['linux', 'darwin'].includes(platform)) {
51+
throw new Error('Architecture or platform is not compatible with Lightpanda')
52+
}
53+
54+
const platformPath = PLATFORMS?.[CURRENT_PLATFORM]?.[CURRENT_ARCH]
4955

5056
if (!existsSync(DEFAULT_CACHE_FOLDER)) {
5157
mkdirSync(DEFAULT_CACHE_FOLDER, { recursive: true })
@@ -91,7 +97,7 @@ export const download = async (): Promise<void> => {
9197
}
9298

9399
return ''
94-
} catch (e) {
100+
} catch (e: any) {
95101
throw new Error(e)
96102
}
97103
}

packages/browser/src/fetch.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ export const fetch = (url: string, options: LightpandaFetchOptions = defaultOpti
5858
const executablePath = getExecutablePath()
5959
const flags = [
6060
{ flag: `--dump ${dumpOptions?.type ?? 'html'}`, condition: dump },
61-
{ flag: '--insecure_disable_tls_host_verification', condition: disableHostVerification },
62-
{ flag: '--obey_robots', condition: obeyRobots },
63-
{ flag: `--http_proxy ${httpProxy}`, condition: httpProxy },
61+
{ flag: '--insecure-disable-tls-host-verification', condition: disableHostVerification },
62+
{ flag: '--obey-robots', condition: obeyRobots },
63+
{ flag: `--http-proxy ${httpProxy}`, condition: httpProxy },
6464
]
6565
.map(f => (f.condition ? f.flag : ''))
6666
.join(' ')

packages/browser/src/serve.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ export const serve = (options: LightpandaServeOptions = defaultOptions) => {
6262
{ flag: '--port', value: port },
6363
{ flag: '--timeout', value: timeout },
6464
{
65-
flag: '--insecure_disable_tls_host_verification',
65+
flag: '--insecure-disable-tls-host-verification',
6666
value: disableHostVerification,
6767
flagOnly: true,
6868
},
6969
{
70-
flag: '--obey_robots',
70+
flag: '--obey-robots',
7171
value: obeyRobots,
7272
flagOnly: true,
7373
},
74-
{ flag: '--http_proxy', value: httpProxy },
74+
{ flag: '--http-proxy', value: httpProxy },
7575
]
7676
.flatMap(f => (f.value ? [f.flag, !f.flagOnly ? f.value.toString() : ''] : ''))
7777
.filter(f => f !== '')

packages/browser/tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
{
22
"compilerOptions": {
3-
"module": "esnext",
3+
"module": "nodenext",
4+
"moduleResolution": "nodenext",
5+
"types": ["node"],
46
"esModuleInterop": true,
57
"target": "es6",
6-
"moduleResolution": "node",
78
"resolveJsonModule": true,
89
"sourceMap": true,
910
"outDir": "dist",
11+
"declaration": true,
12+
"composite": true,
13+
"declarationMap": true,
1014
"paths": {
1115
"lightpanda/*": ["./src/*"],
1216
"scripts/*": ["./scripts/*"]

0 commit comments

Comments
 (0)