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 (#1285)

[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

---
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with
[ReviewStack](https://reviewstack.dev/lastmile-ai/aiconfig/pull/1285).
* __->__ #1285
* #1284
* #1283
* #1280
  • Loading branch information
rossdanlm authored Feb 22, 2024
2 parents 12af50c + 73a7e8b commit ec9cbb8
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 @@ -59,8 +59,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 @@ -771,17 +771,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 ec9cbb8

Please sign in to comment.