Skip to content

Commit fe85de3

Browse files
authored
chore: enable help option for e debug (#691)
* chore: enable help option for e debug * chore: fix lint
1 parent acf4208 commit fe85de3

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/e-debug.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/usr/bin/env node
22

33
const childProcess = require('child_process');
4-
const commandExistsSync = require('command-exists').sync;
54
const path = require('path');
65

6+
const { sync: commandExistsSync } = require('command-exists');
7+
const program = require('commander');
8+
79
const evmConfig = require('./evm-config');
810
const { fatal } = require('./utils/logging');
911

@@ -12,6 +14,8 @@ const opts = {
1214
stdio: 'inherit',
1315
};
1416

17+
program.description('Run the Electron build with a debugger (gdb or lldb)').action(debug);
18+
1519
function run_gdb(config) {
1620
const electron = evmConfig.execOf(config);
1721
const gdbinit = path.resolve(config.root, 'src', 'tools', 'gdb', 'gdbinit');
@@ -31,22 +35,26 @@ function run_lldb(config) {
3135
childProcess.execFileSync('lldb', args, opts);
3236
}
3337

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+
];
3944

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);
4957
}
50-
} catch (e) {
51-
fatal(e);
5258
}
59+
60+
program.parse(process.argv);

0 commit comments

Comments
 (0)