1
1
#!/usr/bin/env node
2
2
3
3
const childProcess = require ( 'child_process' ) ;
4
- const commandExistsSync = require ( 'command-exists' ) . sync ;
5
4
const path = require ( 'path' ) ;
6
5
6
+ const { sync : commandExistsSync } = require ( 'command-exists' ) ;
7
+ const program = require ( 'commander' ) ;
8
+
7
9
const evmConfig = require ( './evm-config' ) ;
8
10
const { fatal } = require ( './utils/logging' ) ;
9
11
@@ -12,6 +14,8 @@ const opts = {
12
14
stdio : 'inherit' ,
13
15
} ;
14
16
17
+ program . description ( 'Run the Electron build with a debugger (gdb or lldb)' ) . action ( debug ) ;
18
+
15
19
function run_gdb ( config ) {
16
20
const electron = evmConfig . execOf ( config ) ;
17
21
const gdbinit = path . resolve ( config . root , 'src' , 'tools' , 'gdb' , 'gdbinit' ) ;
@@ -31,22 +35,26 @@ function run_lldb(config) {
31
35
childProcess . execFileSync ( 'lldb' , args , opts ) ;
32
36
}
33
37
34
- try {
35
- const choices = [
36
- { exec : 'gdb' , runner : run_gdb } ,
37
- { exec : 'lldb' , runner : run_lldb } ,
38
- ] ;
38
+ function debug ( ) {
39
+ try {
40
+ const choices = [
41
+ { exec : 'gdb' , runner : run_gdb } ,
42
+ { exec : 'lldb' , runner : run_lldb } ,
43
+ ] ;
39
44
40
- const choice = choices . find ( ( choice ) => commandExistsSync ( choice . exec ) ) ;
41
- if ( choice ) {
42
- choice . runner ( evmConfig . current ( ) ) ;
43
- } else {
44
- fatal (
45
- `No debugger found in PATH! Looked for [${ choices
46
- . map ( ( choice ) => `'${ choice . exec } '` )
47
- . join ( ', ' ) } ]`,
48
- ) ;
45
+ const choice = choices . find ( ( choice ) => commandExistsSync ( choice . exec ) ) ;
46
+ if ( choice ) {
47
+ choice . runner ( evmConfig . current ( ) ) ;
48
+ } else {
49
+ fatal (
50
+ `No debugger found in PATH! Looked for [${ choices
51
+ . map ( ( choice ) => `'${ choice . exec } '` )
52
+ . join ( ', ' ) } ]`,
53
+ ) ;
54
+ }
55
+ } catch ( e ) {
56
+ fatal ( e ) ;
49
57
}
50
- } catch ( e ) {
51
- fatal ( e ) ;
52
58
}
59
+
60
+ program . parse ( process . argv ) ;
0 commit comments