🚨 Fix linter warning

This commit is contained in:
Alicia Sykes 2024-04-08 20:36:35 +01:00
parent fd45aa6bd1
commit 18e2338735
1 changed files with 5 additions and 5 deletions

View File

@ -18,15 +18,15 @@ module.exports = async (newConfig, render) => {
// Define constants for the config file // Define constants for the config file
const settings = { const settings = {
defaultLocation: './public/', defaultLocation: './user-data/',
defaultFile: 'conf.yml', defaultFile: 'conf.yml',
filename: 'conf', filename: 'conf',
backupDenominator: '.backup.yml', backupDenominator: '.backup.yml',
}; };
// Make the full file name and path to save the backup config file // Make the full file name and path to save the backup config file
const backupFilePath = path.normalize(process.env.BACKUP_DIR || settings.defaultLocation) const backupFilePath = `${path.normalize(process.env.BACKUP_DIR || settings.defaultLocation)
+ `/${usersFileName || settings.filename}-` }/${usersFileName || settings.filename}-`
+ `${Math.round(new Date() / 1000)}${settings.backupDenominator}`; + `${Math.round(new Date() / 1000)}${settings.backupDenominator}`;
// The path where the main conf.yml should be read and saved to // The path where the main conf.yml should be read and saved to
@ -48,12 +48,12 @@ module.exports = async (newConfig, render) => {
// Makes a backup of the existing config file // Makes a backup of the existing config file
await fsPromises await fsPromises
.copyFile(defaultFilePath, backupFilePath) .copyFile(defaultFilePath, backupFilePath)
.catch((error) => render(getRenderMessage(false, `Unable to backup conf.yml: ${error}`))); .catch((error) => render(getRenderMessage(false, `Unable to backup ${settings.defaultFile}: ${error}`)));
// Writes the new content to the conf.yml file // Writes the new content to the conf.yml file
await fsPromises await fsPromises
.writeFile(defaultFilePath, newConfig.config.toString(), writeFileOptions) .writeFile(defaultFilePath, newConfig.config.toString(), writeFileOptions)
.catch((error) => render(getRenderMessage(false, `Unable to write to conf.yml: ${error}`))); .catch((error) => render(getRenderMessage(false, `Unable to write to ${settings.defaultFile}: ${error}`)));
// If successful, then render hasn't yet been called- call it // If successful, then render hasn't yet been called- call it
await render(getRenderMessage(true)); await render(getRenderMessage(true));