mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Extracted getBackupFilePath out of route settings module
refs https://linear.app/tryghost/issue/CORE-35/refactor-route-and-redirect-settings
refs e457fd5fe0 (diff-b292e8480eee007786cc602f55ed05006a06b8da9fe6934d51fbef8328013278R36)
- The method is used in a similar fassion in redirects modules, so should be a gret target for extraction and reuse.
- Bonuses: we drop 'path' and 'moment-timezone' dependencies from route settings module!
This commit is contained in:
parent
6d6aa12afe
commit
a9d742c2d3
2 changed files with 4 additions and 11 deletions
|
@ -1,7 +1,5 @@
|
|||
const Promise = require('bluebird');
|
||||
const moment = require('moment-timezone');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const crypto = require('crypto');
|
||||
const urlService = require('../url');
|
||||
|
||||
|
@ -43,11 +41,6 @@ const messages = {
|
|||
const filename = 'routes';
|
||||
const ext = 'yaml';
|
||||
|
||||
const getBackupFilePath = () => {
|
||||
const settingsFolder = config.getContentPath('settings');
|
||||
return path.join(settingsFolder, `${filename}-${moment().format('YYYY-MM-DD-HH-mm-ss')}.${ext}`);
|
||||
};
|
||||
|
||||
const createBackupFile = async (settingsPath, backupPath) => {
|
||||
return await fs.copy(settingsPath, backupPath);
|
||||
};
|
||||
|
@ -79,7 +72,7 @@ const readFile = (settingsFilePath) => {
|
|||
|
||||
const setFromFilePath = async (filePath) => {
|
||||
const settingsPath = settingsPathManager.getDefaultFilePath();
|
||||
const backupPath = getBackupFilePath();
|
||||
const backupPath = settingsPathManager.getBackupFilePath();
|
||||
|
||||
await createBackupFile(settingsPath, backupPath);
|
||||
await saveFile(filePath, settingsPath);
|
||||
|
|
|
@ -3979,9 +3979,9 @@ data-urls@^3.0.1:
|
|||
whatwg-url "^10.0.0"
|
||||
|
||||
date-fns@^2.24.0:
|
||||
version "2.26.0"
|
||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.26.0.tgz#fa45305543c392c4f914e50775fd2a4461e60fbd"
|
||||
integrity sha512-VQI812dRi3cusdY/fhoBKvc6l2W8BPWU1FNVnFH9Nttjx4AFBRzfSVb/Eyc7jBT6e9sg1XtAGsYpBQ6c/jygbg==
|
||||
version "2.24.0"
|
||||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.24.0.tgz#7d86dc0d93c87b76b63d213b4413337cfd1c105d"
|
||||
integrity sha512-6ujwvwgPID6zbI0o7UbURi2vlLDR9uP26+tW6Lg+Ji3w7dd0i3DOcjcClLjLPranT60SSEFBwdSyYwn/ZkPIuw==
|
||||
|
||||
dateformat@~3.0.3:
|
||||
version "3.0.3"
|
||||
|
|
Loading…
Add table
Reference in a new issue