|
1 | 1 | import * as path from 'path';
|
2 | 2 | import { promises as fs } from 'fs';
|
| 3 | +import { homedir } from 'os'; |
3 | 4 | import { spawn } from 'child_process';
|
4 | 5 | import deepEqual from 'deep-equal';
|
5 | 6 | import WebRequest from 'web-request';
|
@@ -44,6 +45,10 @@ interface DebugConfig {
|
44 | 45 | * If not defined, it falls back to `sketchPath/.vscode/launch.json`.
|
45 | 46 | */
|
46 | 47 | readonly configPath?: string;
|
| 48 | + /** |
| 49 | + * Absolute path to the `arduino-cli.yaml` file. If not specified, it falls back to `~/.arduinoIDE/arduino-cli.yaml`. |
| 50 | + */ |
| 51 | + readonly cliConfigPath?: string; |
47 | 52 | }
|
48 | 53 |
|
49 | 54 | interface DebugInfo {
|
@@ -133,10 +138,15 @@ async function exec(command: string, args: string[]): Promise<{ stdout: string,
|
133 | 138 | });
|
134 | 139 | }
|
135 | 140 |
|
| 141 | +function resolveCliConfigPath(config: DebugConfig): string { |
| 142 | + return config.configPath ?? path.join(homedir(), '.arduinoIDE', 'arduino-cli.yaml'); |
| 143 | +} |
| 144 | + |
136 | 145 | async function startDebug(_: ExtensionContext, config: DebugConfig): Promise<boolean> {
|
| 146 | + const cliConfigPath = resolveCliConfigPath(config); |
137 | 147 | let info: DebugInfo | undefined = undefined;
|
138 | 148 | try {
|
139 |
| - const args = ['debug', '-I', '-b', config.board.fqbn, config.sketchPath, '--format', 'json']; |
| 149 | + const args = ['debug', '-I', '-b', config.board.fqbn, config.sketchPath, '--format', 'json', '--config-file', `"${cliConfigPath}"`]; |
140 | 150 | const { stdout, stderr } = await exec(config?.cliPath || '.', args);
|
141 | 151 | if (!stdout && stderr) {
|
142 | 152 | throw new Error(stderr);
|
|
0 commit comments