Fix issues and add linting
This commit is contained in:
@@ -34,7 +34,12 @@ export function writeContentFile(
|
||||
const existing = fs.readFileSync(absPath, 'utf-8');
|
||||
beforeHash = fileHash(existing);
|
||||
|
||||
const backupDir = path.join(REPO_ROOT, 'content', '.backups', repoRelativePath);
|
||||
// Derive a clean backup subdirectory name from the repo-relative path.
|
||||
// e.g. "content/sections/hero.json" → "sections/hero" (strip leading content/ and .json)
|
||||
const stripped = repoRelativePath
|
||||
.replace(/^content\//, '')
|
||||
.replace(/\.json$/, '');
|
||||
const backupDir = path.join(REPO_ROOT, 'content', '.backups', stripped);
|
||||
ensureDir(backupDir);
|
||||
const ts = new Date().toISOString().replace(/[:.]/g, '-');
|
||||
fs.copyFileSync(absPath, path.join(backupDir, `${ts}.json`));
|
||||
|
||||
Reference in New Issue
Block a user