diff --git a/src/extension.ts b/src/extension.ts index 36ddf20..68b12fc 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,5 @@ -import * as fs from 'fs'; import * as path from 'path'; -import { promisify } from 'util'; +import { promises as fs } from 'fs'; import { spawnSync } from 'child_process'; import deepEqual from 'deep-equal'; import WebRequest from 'web-request'; @@ -35,6 +34,11 @@ interface DebugConfig { readonly name?: string; } readonly sketchPath: string; + /** + * Location where the `launch.config` will be created on the fly before starting every debug session. + * If not defined, it falls back to `sketchPath/.vscode/launch.json`. + */ + readonly configPath?: string; } interface DebugInfo { @@ -140,13 +144,10 @@ async function startDebug(_: ExtensionContext, config: DebugConfig): Promise { + if (debugConfig.configPath) { + await fs.mkdir(debugConfig.configPath, { recursive: true }); + await fs.writeFile(path.join(debugConfig.configPath, 'launch.json'), JSON.stringify(launchConfig, null, 2)); + } else { + const configuration = vscode.workspace.getConfiguration(); + await configuration.update('launch', launchConfig, false); + } +}