mirror of
https://git.qoto.org/fedipage/fedipage.git
synced 2024-11-15 19:47:57 +01:00
37 lines
982 B
JavaScript
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);
|
|
});
|