fedipage/clean-build.cjs
Jeffrey Phillips Freeman 945d28952f
Fixed the hack, I hope
2023-10-13 14:52:54 -04:00

37 lines
982 B
JavaScript

'use strict';
const path = require('path');
const fs = require('fs');
const listDir = (dir, fileList = [], active = false ) => {
let files = fs.readdirSync(dir);
files.forEach(file => {
if (fs.statSync(path.join(dir, file)).isDirectory()) {
if(! ("page" === file) ) {
fileList = listDir(path.join(dir, file), fileList, true);
}
} else {
if( (/^index\.html$/.test(file)) && (active) ) {
const name = 'status.html';
let src = path.join(dir, file);
let newSrc = path.join(dir, name);
fileList.push({
oldSrc: src,
newSrc: newSrc
});
}
}
});
return fileList;
};
let foundFiles = listDir( './public/news');
listDir('./public/resource', foundFiles);
listDir('./public/projects', foundFiles);
foundFiles.forEach(f => {
fs.renameSync(f.oldSrc, f.newSrc);
});