1-
21/* eslint-disable @typescript-eslint/no-require-imports */
2+ /* eslint-disable no-console */
33const { spawnSync } = require ( 'child_process' )
44const fs = require ( 'fs' )
55const path = require ( 'path' )
66
77function 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
1515const cwd = process . cwd ( )
@@ -24,23 +24,23 @@ console.log(' - resources exists:', exists(buildResources), buildResources)
2424console . log ( ' - electron-output exists:' , exists ( electronOutput ) , electronOutput )
2525
2626if ( ! 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
3131function 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
4646list ( 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`.
5858const 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} )
6363const argString = quotedArgs . join ( ' ' )
6464cmdParts . push ( `npx electron-builder ${ argString } ` )
@@ -68,11 +68,14 @@ const shellCmd = cmdParts.join(' || ')
6868
6969const shellRes = spawnSync ( shellCmd , { stdio : 'inherit' , shell : true } )
7070if ( 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}
7475if ( 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
7881process . exit ( 0 )
0 commit comments