mirror of
https://gitlab.com/Thoscellen/Wallset.git
synced 2025-05-31 19:04:51 +02:00
Détecte si un thème est déjà présent
Et ignore sa génération dans ce cas.
This commit is contained in:
parent
9ac05f338b
commit
98878bd6b6
@ -1,18 +1,23 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const iptc = require("node-iptc");
|
||||
const { exit } = require("process");
|
||||
|
||||
|
||||
// find all images
|
||||
// Fetch envs to target the right folder
|
||||
const slug = process.env["PACKAGE_NAME"];
|
||||
const root = process.env["ENTRY_FOLDER"];
|
||||
if (!slug || !root) exit(1);
|
||||
let workingDirectory = path.join(root, slug);
|
||||
|
||||
// extract metadata from them
|
||||
fs.readdir(workingDirectory, (err, files) => {
|
||||
if (err) { throw err };
|
||||
if (err) { throw err }; // If IO error, exit with an error message
|
||||
|
||||
// construct a JSON file
|
||||
// If there is already a theme.json silentely exit and let mocha running afterwards
|
||||
if (!files.find(file => path.extname(file) == '.json')) exit(0);
|
||||
|
||||
// construct a JSON object
|
||||
let theme = new Object();
|
||||
theme.dayImageList = [];
|
||||
theme.nightImageList = [];
|
||||
@ -63,7 +68,7 @@ fs.readdir(workingDirectory, (err, files) => {
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
// make it the theme.json
|
||||
fs.writeFileSync(path.join(workingDirectory, 'theme.json'), JSON.stringify(theme));
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user