Skip to content

Commit

Permalink
[vscode][5/n] Setup Env Variables: Read the text from the env templat…
Browse files Browse the repository at this point in the history
…e and append to existing file

TSIA, and making the function async now that we call an await statement


## Test Plan

https://github.com/lastmile-ai/aiconfig/assets/151060367/6679e13d-6d58-4ec4-a237-360cb273e59c
  • Loading branch information
Rossdan Craig [email protected] committed Feb 22, 2024
1 parent 351c376 commit 73a7e8b
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(
vscode.commands.registerCommand(
COMMANDS.SETUP_ENVIRONMENT_VARIABLES,
() => {
setupEnvironmentVariables(context);
async () => {
await setupEnvironmentVariables(context);
}
)
);
Expand Down Expand Up @@ -764,17 +764,13 @@ async function setupEnvironmentVariables(context: vscode.ExtensionContext) {
);

if (fs.existsSync(envPath)) {
var helperText: string = "\ntest, will change next PR";
// fs.readFile(envTemplatePath.fsPath, function read(err, data) {
// if (err) {
// throw err;
// }
// helperText = "\n" + data.toString();
// });
const helperText = (
await vscode.workspace.fs.readFile(envTemplatePath)
).toString();

// TODO: Check if we already appended the template text to existing .env
// file before. If we did, don't do it again
fs.appendFile(envPath, helperText, function (err) {
fs.appendFile(envPath, "\n\n" + helperText, function (err) {
if (err) {
throw err;
}
Expand Down

0 comments on commit 73a7e8b

Please sign in to comment.