Skip to content

Commit

Permalink
setEnvFile: fix error when no .env file (#1237)
Browse files Browse the repository at this point in the history
  • Loading branch information
error7404 authored Sep 1, 2024
1 parent 3597b54 commit be4ed6d
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions scripts/setEnvFile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@ let data =
os.EOL +
`RELEASE_DATE=${formattedDate}`;

let existingEnvData = '';

fs.readFile(path.join(__dirname, '..', '.env'), 'utf8', (err, existingData) => {
if (err) {
console.log(err);
return;
}
if (err) return;

const existingEnvData = existingData
existingEnvData = existingData
.split(os.EOL)
.filter(line => {
return (
Expand All @@ -32,14 +31,14 @@ fs.readFile(path.join(__dirname, '..', '.env'), 'utf8', (err, existingData) => {
);
})
.join(os.EOL);
});

if (existingEnvData) {
data += os.EOL + existingEnvData;
}
if (existingEnvData) {
data += os.EOL + existingEnvData;
}

fs.writeFile(path.join(__dirname, '..', '.env'), data, 'utf8', err => {
if (err) {
console.log(err);
}
});
fs.writeFile(path.join(__dirname, '..', '.env'), data, 'utf8', err => {
if (err) {
console.log(err);
}
});

0 comments on commit be4ed6d

Please sign in to comment.