fixes asynchronous error
parent
5b46f36c58
commit
7476c55e63
14
gulpfile.mjs
14
gulpfile.mjs
|
|
@ -60,15 +60,15 @@ const convert = async function (from, to, ofType, overwrite = true) {
|
|||
mkdirSync(DEST)
|
||||
}
|
||||
|
||||
const filewalker = (source) => {
|
||||
const filewalker = async (source) => {
|
||||
console.debug("entering directory", source);
|
||||
readdirSync(source).forEach(file => {
|
||||
for (let file of readdirSync(source)) {
|
||||
if (statSync(join(source, file)).isDirectory()) {
|
||||
filewalker(join(source, file));
|
||||
await filewalker(join(source, file));
|
||||
} else {
|
||||
console.debug("processing file", join(source, file))
|
||||
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}));
|
||||
randomID("DSA_4-1" + TYPE + originalSource.name.trim()).then(id => {
|
||||
let id = await randomID("DSA_4-1" + TYPE + originalSource.name.trim())
|
||||
|
||||
let targetSource = {
|
||||
_id: id,
|
||||
|
|
@ -82,13 +82,11 @@ const convert = async function (from, to, ofType, overwrite = true) {
|
|||
let target = JSON.stringify(targetSource, null, 2);
|
||||
let newFileName = "./" + join(DEST, id + ".json");
|
||||
writeFileSync(newFileName, target, {encoding: "utf8"});
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
filewalker(SOURCE)
|
||||
|
||||
return await filewalker(SOURCE)
|
||||
}
|
||||
|
||||
function cleanDist() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue