@@ -314,23 +314,34 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
314
314
// we do this after the user has entered the filename
315
315
try {
316
316
const workspaceFolder = vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath ;
317
- const { type } = await vscode . workspace . fs . stat ( vscode . Uri . file ( `${ workspaceFolder } /${ fileName } ` ) ) ;
317
+ const { type } = await vscode . workspace . fs . stat ( vscode . Uri . file ( `${ workspaceFolder } /.devproxy/ ${ fileName } ` ) ) ;
318
318
if ( type === vscode . FileType . File ) {
319
319
vscode . window . showErrorMessage ( 'A file with that name already exists' ) ;
320
320
return ;
321
321
}
322
322
} catch { } // file does not exist, continue
323
323
324
324
try {
325
+ // ensure .devproxy folder exists
326
+ const workspaceFolder = vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath ;
327
+ const devProxyFolder = vscode . Uri . file ( `${ workspaceFolder } /.devproxy` ) ;
328
+
329
+ try {
330
+ await vscode . workspace . fs . stat ( devProxyFolder ) ;
331
+ } catch {
332
+ // folder doesn't exist, create it
333
+ await vscode . workspace . fs . createDirectory ( devProxyFolder ) ;
334
+ }
335
+
325
336
// show progress
326
337
await vscode . window . withProgress ( {
327
338
location : vscode . ProgressLocation . Notification ,
328
339
title : 'Creating new config file...'
329
340
} , async ( ) => {
330
- await executeCommand ( `${ devProxyExe } config new ${ fileName } ` , { cwd : vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath } ) ;
341
+ await executeCommand ( `${ devProxyExe } config new ${ fileName } ` , { cwd : ` ${ workspaceFolder } /.devproxy` } ) ;
331
342
} ) ;
332
343
333
- const configUri = vscode . Uri . file ( `${ vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath } /${ fileName } ` ) ;
344
+ const configUri = vscode . Uri . file ( `${ workspaceFolder } /.devproxy /${ fileName } ` ) ;
334
345
const document = await vscode . workspace . openTextDocument ( configUri ) ;
335
346
await vscode . window . showTextDocument ( document ) ;
336
347
} catch ( error ) {
0 commit comments