update removeDarkmode script, ref #112
This commit is contained in:
parent
55ed912d63
commit
7c177108db
@ -13,6 +13,34 @@ const configFiles = [
|
||||
},
|
||||
];
|
||||
|
||||
// asset paths
|
||||
const deleteAssetList = [
|
||||
"exampleSite/assets/images/logo-darkmode.png",
|
||||
"layouts/partials/components/theme-switcher.html",
|
||||
];
|
||||
|
||||
const filePaths = [
|
||||
{
|
||||
filePath: "layouts/partials/essentials/header.html",
|
||||
patterns: [
|
||||
'{{\\s*partial\\s*"components\\/theme-switcher"\\s*\\([^)]*\\)\\s*}}',
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
filePaths.forEach(({ filePath, patterns }) =>
|
||||
removeDarkModeFromFiles(filePath, patterns),
|
||||
);
|
||||
|
||||
deleteAssetList.forEach((asset) => {
|
||||
try {
|
||||
fs.unlinkSync(asset);
|
||||
console.log(`${path.basename(asset)} deleted successfully!`);
|
||||
} catch (error) {
|
||||
console.error(`${asset} not found`);
|
||||
}
|
||||
});
|
||||
|
||||
rootDirs.forEach(removeDarkModeFromPages);
|
||||
configFiles.forEach(removeDarkMode);
|
||||
|
||||
@ -23,9 +51,11 @@ function removeDarkModeFromFiles(filePath, regexPatterns) {
|
||||
const regex = new RegExp(pattern, "g");
|
||||
updatedContent = updatedContent.replace(regex, "");
|
||||
});
|
||||
|
||||
fs.writeFileSync(filePath, updatedContent, "utf8");
|
||||
}
|
||||
|
||||
// like html file
|
||||
function removeDarkModeFromPages(directoryPath) {
|
||||
const files = fs.readdirSync(directoryPath);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user