-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcleanExercise.ts
31 lines (26 loc) · 984 Bytes
/
cleanExercise.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import * as vscode from "vscode";
import { ActionContext } from "../actions/types";
import { Logger } from "../utilities";
/**
* Removes language specific meta files from exercise directory.
*/
export async function cleanExercise(
actionContext: ActionContext,
resource: vscode.Uri | undefined,
): Promise<void> {
const { dialog, tmc, workspaceManager } = actionContext;
Logger.info("Cleaning exercise");
if (resource && !workspaceManager.uriIsExercise(resource)) {
dialog.errorNotification("Currently open editor is not part of a TMC exercise.");
return;
}
const exerciseToClean = resource ?? workspaceManager.activeExercise?.uri;
if (!exerciseToClean) {
Logger.warn("Attempted to clean an exercise without target.");
return;
}
const cleanResult = await tmc.clean(exerciseToClean.fsPath);
if (cleanResult.err) {
dialog.errorNotification("Failed to clean exercise.", cleanResult.val);
}
}