Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed:

- Snippets: All snippets that reference schemas updated to use `v1.0.0` schema
- Commands: `dev-proxy-toolkit.config-new` now creates the configuration file in the `.devproxy` folder and creates the folder if it does not exist

### Fixed:

Expand Down
17 changes: 14 additions & 3 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,23 +314,34 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration
// we do this after the user has entered the filename
try {
const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
const { type } = await vscode.workspace.fs.stat(vscode.Uri.file(`${workspaceFolder}/${fileName}`));
const { type } = await vscode.workspace.fs.stat(vscode.Uri.file(`${workspaceFolder}/.devproxy/${fileName}`));
if (type === vscode.FileType.File) {
vscode.window.showErrorMessage('A file with that name already exists');
return;
}
} catch { } // file does not exist, continue

try {
// ensure .devproxy folder exists
const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
const devProxyFolder = vscode.Uri.file(`${workspaceFolder}/.devproxy`);

try {
await vscode.workspace.fs.stat(devProxyFolder);
} catch {
// folder doesn't exist, create it
await vscode.workspace.fs.createDirectory(devProxyFolder);
}

// show progress
await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: 'Creating new config file...'
}, async () => {
await executeCommand(`${devProxyExe} config new ${fileName}`, { cwd: vscode.workspace.workspaceFolders?.[0].uri.fsPath });
await executeCommand(`${devProxyExe} config new ${fileName}`, { cwd: `${workspaceFolder}/.devproxy` });
});

const configUri = vscode.Uri.file(`${vscode.workspace.workspaceFolders?.[0].uri.fsPath}/${fileName}`);
const configUri = vscode.Uri.file(`${workspaceFolder}/.devproxy/${fileName}`);
const document = await vscode.workspace.openTextDocument(configUri);
await vscode.window.showTextDocument(document);
} catch (error) {
Expand Down
Loading