Skip to content

Commit

Permalink
Updated logic to handle duplicate entries
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyanotfound committed Oct 28, 2024
1 parent bc64d4d commit 2c0942f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ export async function main(): Promise<void> {
});

const websocketUrl = endpoint.replace(/^http(s)?:\/\//, 'ws$1://');
fs.appendFileSync(
'.env',
`REACT_APP_BACKEND_WEBSOCKET_URL=${websocketUrl}\n`,
);
const currentWebSocketUrl = dotenv.parse(
fs.readFileSync('.env'),
).REACT_APP_BACKEND_WEBSOCKET_URL;

fs.readFile('.env', 'utf8', (err, data) => {
if (err) {
console.error('Error reading .env file:', err);
process.exit(1);
}
const result = data.replace(
`REACT_APP_BACKEND_WEBSOCKET_URL=${currentWebSocketUrl}`,
`REACT_APP_BACKEND_WEBSOCKET_URL=${websocketUrl}`,
);
fs.writeFileSync('.env', result, 'utf8');
});
}

const { shouldUseRecaptcha } = await inquirer.prompt({
Expand Down

0 comments on commit 2c0942f

Please sign in to comment.