Skip to content

Commit 859250d

Browse files
committed
Refactored 1)
1 parent 67ea9fb commit 859250d

18 files changed

Lines changed: 1674 additions & 1547 deletions

src/callbacks.ts

Lines changed: 13 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -30,59 +30,11 @@ import {
3030
const fs = require("fs");
3131
const path = require("path");
3232

33-
export async function addEnvToProjectCallback(
34-
enviroPath: string,
35-
code: number
36-
) {
37-
// This function gets called after we add an environment to a project.
38-
// We check the return code, update Project Tree, and cleanup on failure
39-
40-
if (code == 0) {
41-
await refreshAllExtensionData();
42-
} else {
43-
try {
44-
// remove the environment directory, as well as the .vce file
45-
vectorMessage("Environment adding failed, removing artifacts ...");
46-
fs.rmSync(enviroPath, { recursive: true, force: true });
47-
fs.unlinkSync(enviroPath + ".vce");
48-
// Don't want to remove the .env, because leaving it allows the
49-
// user to edit and then right click to try a re-build
50-
} catch {
51-
// ignore errors
52-
}
53-
}
54-
}
55-
5633
/**
57-
* Callback function for executing buildEnvironmentIncremental command
58-
* @param enviroPathList List of env path
59-
* @param code Exit code
34+
* Callback function when we build a single (Project-) Environment
35+
* @param enviroPath Path to env
36+
* @param code Exit code of the process
6037
*/
61-
export async function buildEnvironmentIncrementalCallback(
62-
enviroPathList: string[],
63-
code: number
64-
) {
65-
// This function gets called after we build an environment
66-
// We check the return code, update the test pane, and cleanup on failure
67-
68-
for (let enviroPath of enviroPathList) {
69-
if (code == 0) {
70-
await updateDataForEnvironment(enviroPath);
71-
} else {
72-
try {
73-
// remove the environment directory, as well as the .vce file
74-
vectorMessage("Environment build failed, removing artifacts ...");
75-
fs.rmSync(enviroPath, { recursive: true, force: true });
76-
fs.unlinkSync(enviroPath + ".vce");
77-
// Don't want to remove the .env, because leaving it allows the
78-
// user to edit and then right click to try a re-build
79-
} catch {
80-
// ignore errors
81-
}
82-
}
83-
}
84-
}
85-
8638
export async function buildEnvironmentCallback(
8739
enviroPath: string,
8840
code: number
@@ -108,6 +60,11 @@ export async function buildEnvironmentCallback(
10860
}
10961
}
11062

63+
/**
64+
* Callback function when we re-build a single (Project-) Environment
65+
* @param enviroPath Path to env
66+
* @param code Exit code of the process
67+
*/
11168
export async function rebuildEnvironmentCallback(
11269
enviroPath: string,
11370
code: number
@@ -131,37 +88,11 @@ export async function rebuildEnvironmentCallback(
13188
}
13289
}
13390

134-
export async function cleanEnvironmentCallback(
135-
enviroNodeID: string,
136-
code: number
137-
) {
138-
// if the delete succeeded then we need to remove the environment from the test pane
139-
if (code == 0) {
140-
removeCBTfilesCacheForEnviro(enviroNodeID);
141-
let enviroPath = getEnviroPathFromID(enviroNodeID);
142-
if (!enviroPath) {
143-
// We check if it is present in the unbuilt list
144-
// If so, we take the id and split it after "vcast:" to get the path
145-
// In case that is not possible, we throw an error message
146-
if (vcastUnbuiltEnviroList.includes(enviroNodeID)) {
147-
const parts = enviroNodeID.split(":");
148-
enviroPath = parts.slice(1).join(":");
149-
} else {
150-
vscode.window.showErrorMessage(
151-
`Unable to determine environment path from node: ${enviroNodeID}`
152-
);
153-
return;
154-
}
155-
}
156-
157-
removeCoverageDataForEnviro(enviroPath);
158-
await refreshAllExtensionData();
159-
160-
// vcast does not delete the ENVIRO-NAME.* files so we clean those up here
161-
removeFilePattern(enviroPath, ".*");
162-
}
163-
}
164-
91+
/**
92+
* Callback function when we delete a single Environment
93+
* @param enviroPath Path to env
94+
* @param code Exit code of the process
95+
*/
16596
export async function deleteEnvironmentCallback(
16697
enviroNodeID: string,
16798
code: number

0 commit comments

Comments
 (0)