Skip to content

Commit 0aa5ae6

Browse files
scripts(tsr-bridge): fix lint warnings in prep-build-binary.cjs (no-console, catch binding)
1 parent 91cf081 commit 0aa5ae6

1 file changed

Lines changed: 29 additions & 26 deletions

File tree

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
21
/* eslint-disable @typescript-eslint/no-require-imports */
2+
/* eslint-disable no-console */
33
const { spawnSync } = require('child_process')
44
const fs = require('fs')
55
const path = require('path')
66

77
function exists(p) {
8-
try {
9-
return fs.existsSync(p)
10-
} catch (e) {
11-
return false
12-
}
8+
try {
9+
return fs.existsSync(p)
10+
} catch {
11+
return false
12+
}
1313
}
1414

1515
const cwd = process.cwd()
@@ -24,23 +24,23 @@ console.log(' - resources exists:', exists(buildResources), buildResources)
2424
console.log(' - electron-output exists:', exists(electronOutput), electronOutput)
2525

2626
if (!exists(distDir)) {
27-
console.warn('prep-build-binary: WARNING: dist/ directory missing. Run `yarn workspace tsr-bridge build` first.')
27+
console.warn('prep-build-binary: WARNING: dist/ directory missing. Run `yarn workspace tsr-bridge build` first.')
2828
}
2929

3030
// Print a short listing to help CI debug
3131
function list(dir) {
32-
if (!exists(dir)) return
33-
console.log('\nListing ' + dir)
34-
try {
35-
const items = fs.readdirSync(dir)
36-
for (const it of items.slice(0, 200)) {
37-
const p = path.join(dir, it)
38-
const st = fs.statSync(p)
39-
console.log(`${st.isDirectory() ? 'd' : '-'} ${st.size.toString().padStart(8)} ${it}`)
40-
}
41-
} catch (err) {
42-
console.error('Error listing', dir, err && err.stack ? err.stack : err)
43-
}
32+
if (!exists(dir)) return
33+
console.log('\nListing ' + dir)
34+
try {
35+
const items = fs.readdirSync(dir)
36+
for (const it of items.slice(0, 200)) {
37+
const p = path.join(dir, it)
38+
const st = fs.statSync(p)
39+
console.log(`${st.isDirectory() ? 'd' : '-'} ${st.size.toString().padStart(8)} ${it}`)
40+
}
41+
} catch (err) {
42+
console.error('Error listing', dir, err && err.stack ? err.stack : err)
43+
}
4444
}
4545

4646
list(cwd)
@@ -56,9 +56,9 @@ console.log('\nRunning electron-builder with args:', args.join(' '))
5656
// cause spawnSync to throw ENOENT on Windows/CI. Try `npx`, then `yarn`, then
5757
// the local `node_modules/.bin/electron-builder`.
5858
const cmdParts = []
59-
const quotedArgs = args.map(a => {
60-
if (/\s/.test(a)) return '"' + a.replace(/"/g, '\\"') + '"'
61-
return a
59+
const quotedArgs = args.map((a) => {
60+
if (/\s/.test(a)) return '"' + a.replace(/"/g, '\\"') + '"'
61+
return a
6262
})
6363
const argString = quotedArgs.join(' ')
6464
cmdParts.push(`npx electron-builder ${argString}`)
@@ -68,11 +68,14 @@ const shellCmd = cmdParts.join(' || ')
6868

6969
const shellRes = spawnSync(shellCmd, { stdio: 'inherit', shell: true })
7070
if (shellRes && shellRes.error) {
71-
console.error('prep-build-binary: spawn error', shellRes.error)
72-
process.exit(1)
71+
console.error('prep-build-binary: spawn error', shellRes.error)
72+
// eslint-disable-next-line n/no-process-exit
73+
process.exit(1)
7374
}
7475
if (typeof shellRes.status === 'number' && shellRes.status !== 0) {
75-
console.error('prep-build-binary: electron-builder exited with code', shellRes.status)
76-
process.exit(shellRes.status)
76+
console.error('prep-build-binary: electron-builder exited with code', shellRes.status)
77+
// eslint-disable-next-line n/no-process-exit
78+
process.exit(shellRes.status)
7779
}
80+
// eslint-disable-next-line n/no-process-exit
7881
process.exit(0)

0 commit comments

Comments
 (0)