Skip to content

Commit

Permalink
Da 451 release bug fix (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
lokesh-couchbase authored May 29, 2024
1 parent 4c02da3 commit 15a3398
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/util/namedParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,31 @@ export function getUsersNamedParameters(): IKeyValuePair[] {
).map(([key, value]) => ({ key, value }));
return userNamedParameters;
} catch (error) {
console.error("Error reading userNamedParameters from config:", error);
console.log("Error reading userNamedParameters from config:", error);
return [];
}
}

export function getProjectsNamedParameters(): IKeyValuePair[] {
const workspaceFolders = vscode.workspace.workspaceFolders;
if (workspaceFolders && workspaceFolders.length > 0) {
const rootPath = workspaceFolders[0].uri.fsPath;
const filePath = path.join(rootPath, '.cbNamedParams.properties');
let namedParameters: IKeyValuePair[] = [];
try {
const rootPath = workspaceFolders[0].uri.fsPath;
const filePath = path.join(rootPath, '.cbNamedParams.properties');
const fileContent = fs.readFileSync(filePath, 'utf-8');
const lines = fileContent.split('\n');

for (let line of lines) {
const [key, value] = line.split('=');
namedParameters.push({ key: key.trim(), value: value.trim() });
}
} catch (error) {
console.error('Error reading .cbNamedParams.properties file:', error);
} catch (error: any) {
if (error.code === 'ENOENT') {
console.log('.cbNamedParams.properties file does not exist');
} else {
console.error('Error reading .cbNamedParams.properties file:', error);
}
}
return namedParameters;
} else {
Expand Down

0 comments on commit 15a3398

Please sign in to comment.