Skip to content
Open
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
22 changes: 21 additions & 1 deletion src/foundry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ import * as vscode from 'vscode';
import {getConfigValue} from './utils';
import {parse as parseToml} from 'smol-toml';

export
function forgeCleanTask(file: string) {
const forgePath = getConfigValue('forge-path', 'forge');
const cwd = file.substring(0, file.lastIndexOf('/'));
const task = new vscode.Task(
{
label: 'forge clean',
type: 'shell',
},
vscode.TaskScope.Workspace,
'forge',
'simbolik',
new vscode.ShellExecution(forgePath, ['clean'], {
cwd,
})
);
task.isBackground = true;
task.presentationOptions.reveal = vscode.TaskRevealKind.Always;
return task;
}

export
function forgeBuildTask(file: string) {
Expand Down Expand Up @@ -110,4 +130,4 @@ async function getSortedFilesByCreationTime(buildInfoDir: string, buildInfoFiles

// Sort files by creation time (ctime)
return filesWithStats.sort((a, b) => b.ctime - a.ctime);
}
}
9 changes: 8 additions & 1 deletion src/startDebugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import * as vscode from 'vscode';
import { getConfigValue } from './utils';
import { Supervisor } from './supevervisor';
import { forgeBuildTask, foundryRoot, loadBuildInfo } from './foundry';
import { forgeCleanTask, forgeBuildTask, foundryRoot, loadBuildInfo } from './foundry';

export async function startDebugging(
this: Supervisor,
Expand Down Expand Up @@ -63,6 +63,13 @@ export async function startDebugging(
const rpcUrl = `http://localhost:${anvilPort}`;
const autobuild = getConfigValue('autobuild', true);
if (autobuild) {
const clean = forgeCleanTask(activeTextEditor.document.uri.fsPath);
const cleanExecution = await vscode.tasks.executeTask(clean);
try {
await completed(cleanExecution);
} catch (e) {
vscode.window.showErrorMessage('Failed to clean project.');
}
const build = forgeBuildTask(activeTextEditor.document.uri.fsPath);
const buildExecution = await vscode.tasks.executeTask(build);
try {
Expand Down