From 73a7e8b6d588e37badec2b10da846d7e452c7e72 Mon Sep 17 00:00:00 2001 From: "Rossdan Craig rossdan@lastmileai.dev" <> Date: Wed, 21 Feb 2024 19:59:13 -0500 Subject: [PATCH] [vscode][5/n] Setup Env Variables: Read the text from the env template 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 --- vscode-extension/src/extension.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/vscode-extension/src/extension.ts b/vscode-extension/src/extension.ts index 74cfc9416..e2436a763 100644 --- a/vscode-extension/src/extension.ts +++ b/vscode-extension/src/extension.ts @@ -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); } ) ); @@ -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; }