Specify file read encoding where possible

This commit is contained in:
Cohee 2023-08-30 20:57:19 +03:00 committed by GitHub
parent 938e244987
commit 52dbb916c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -4227,7 +4227,7 @@ app.post('/readsecretstate', jsonParser, (_, response) => {
}
try {
const fileContents = fs.readFileSync(SECRETS_FILE);
const fileContents = fs.readFileSync(SECRETS_FILE, 'utf8');
const secrets = JSON.parse(fileContents);
const state = {};
@ -4286,7 +4286,7 @@ app.post('/viewsecrets', jsonParser, async (_, response) => {
}
try {
const fileContents = fs.readFileSync(SECRETS_FILE, 'utf8');
const fileContents = fs.readFileSync(SECRETS_FILE, 'utf-8');
const secrets = JSON.parse(fileContents);
return response.send(secrets);
} catch (error) {
@ -4872,8 +4872,8 @@ function writeSecret(key, value) {
writeFileAtomicSync(SECRETS_FILE, emptyFile, "utf-8");
}
const fileContents = fs.readFileSync(SECRETS_FILE);
const secrets = JSON.parse(fileContents.toString());
const fileContents = fs.readFileSync(SECRETS_FILE, 'utf-8');
const secrets = JSON.parse(fileContents);
secrets[key] = value;
writeFileAtomicSync(SECRETS_FILE, JSON.stringify(secrets), "utf-8");
}
@ -4883,8 +4883,8 @@ function readSecret(key) {
return undefined;
}
const fileContents = fs.readFileSync(SECRETS_FILE);
const secrets = JSON.parse(fileContents.toString());
const fileContents = fs.readFileSync(SECRETS_FILE, 'utf-8');
const secrets = JSON.parse(fileContents);
return secrets[key];
}