Skip to content

Commit f252bde

Browse files
authored
Reqs excel delete fix (#303)
Fixes the issue that the wrong env state is reflected in the requirements buttons if the reqs esxcel file is deleted manually and not via the extension button.
1 parent b7e3597 commit f252bde

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
All notable changes to the "vectorcastTestExplorer" extension will be documented in this file.
44

5+
## [1.0.24] - 2025-11-14
6+
7+
### Added
8+
- Enabled use of environment variables in CCAST.cfg for requirements logic.
9+
510
## [1.0.23] - 2025-10-08
611

712
### Changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vectorcasttestexplorer",
33
"displayName": "VectorCAST Test Explorer",
44
"description": "VectorCAST Test Explorer for VS Code",
5-
"version": "1.0.23",
5+
"version": "1.0.24",
66
"license": "MIT",
77
"repository": {
88
"type": "git",

src/requirements/requirementsUtils.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,26 @@ export async function parseRequirementsFromFile(
9898
}
9999

100100
export function findEnvironmentInPath(dirPath: string): string | null {
101+
// dirPath will be the path were the requirements are, but the env files are in the parent folder
102+
const parentDir = path.dirname(dirPath);
103+
104+
// the folder is named reqs-<envName>, so we cut out the correct env name to find the corresponding env file
105+
const baseFolder = path.basename(dirPath);
106+
const envName = baseFolder.split("reqs-")[1];
107+
101108
// Check if the directory contains an environment file
102-
const files = fs.readdirSync(dirPath);
103-
const envFiles = files.filter((file: string) => file.endsWith(".env"));
109+
const files = fs.readdirSync(parentDir);
110+
const envFiles = files.filter((file: string) =>
111+
file.endsWith(`${envName}.env`)
112+
);
104113

105114
// Now see if there is a directory with the same name as the env file
106115
for (const file of envFiles) {
107116
// remove ".env"
108117
const envName = file.slice(0, -4);
109-
const envDirPath = path.join(dirPath, envName);
118+
const envDirPath = path.join(parentDir, envName);
110119
if (fs.existsSync(envDirPath) && fs.lstatSync(envDirPath).isDirectory()) {
111-
return envName;
120+
return envDirPath;
112121
}
113122
}
114123
return null;
@@ -125,18 +134,18 @@ export function setupRequirementsFileWatchers(
125134
if (workspace.workspaceFolders && workspace.workspaceFolders.length > 0) {
126135
// Create a file watcher that watches for requirements files changes
127136
// using a glob pattern to match all reqs.csv and reqs.xlsx files in the workspace
128-
requirementsFileWatcher =
129-
workspace.createFileSystemWatcher("**/reqs.{csv,xlsx}");
137+
requirementsFileWatcher = workspace.createFileSystemWatcher(
138+
"**/reqs-*/reqs.{csv,xlsx}"
139+
);
130140

131141
// When a requirements file is created
132142
requirementsFileWatcher.onDidCreate(
133143
async (uri) => {
134144
logCliOperation(`Requirements file created: ${uri.fsPath}`);
135145
const changeDir = path.dirname(uri.fsPath);
136-
const envDirName = findEnvironmentInPath(changeDir);
137-
if (envDirName) {
138-
const envPath = path.join(changeDir, envDirName);
139-
updateRequirementsAvailability(envPath);
146+
const envDirPath = findEnvironmentInPath(changeDir);
147+
if (envDirPath) {
148+
updateRequirementsAvailability(envDirPath);
140149
}
141150
},
142151
null,
@@ -148,10 +157,9 @@ export function setupRequirementsFileWatchers(
148157
async (uri) => {
149158
logCliOperation(`Requirements file deleted: ${uri.fsPath}`);
150159
const parentDir = path.dirname(uri.fsPath);
151-
const envDirName = findEnvironmentInPath(parentDir);
152-
if (envDirName) {
153-
const envPath = path.join(parentDir, envDirName);
154-
updateRequirementsAvailability(envPath);
160+
const envDirPath = findEnvironmentInPath(parentDir);
161+
if (envDirPath) {
162+
updateRequirementsAvailability(envDirPath);
155163
}
156164
},
157165
null,

0 commit comments

Comments
 (0)