@@ -314,23 +314,34 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
314314 // we do this after the user has entered the filename
315315 try {
316316 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 } ` ) ) ;
318318 if ( type === vscode . FileType . File ) {
319319 vscode . window . showErrorMessage ( 'A file with that name already exists' ) ;
320320 return ;
321321 }
322322 } catch { } // file does not exist, continue
323323
324324 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+
325336 // show progress
326337 await vscode . window . withProgress ( {
327338 location : vscode . ProgressLocation . Notification ,
328339 title : 'Creating new config file...'
329340 } , 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` } ) ;
331342 } ) ;
332343
333- const configUri = vscode . Uri . file ( `${ vscode . workspace . workspaceFolders ?. [ 0 ] . uri . fsPath } /${ fileName } ` ) ;
344+ const configUri = vscode . Uri . file ( `${ workspaceFolder } /.devproxy /${ fileName } ` ) ;
334345 const document = await vscode . workspace . openTextDocument ( configUri ) ;
335346 await vscode . window . showTextDocument ( document ) ;
336347 } catch ( error ) {
0 commit comments