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)
|
mkdirSync(DEST)
|
||||||
}
|
}
|
||||||
|
|
||||||
const filewalker = (source) => {
|
const filewalker = async (source) => {
|
||||||
console.debug("entering directory", source);
|
console.debug("entering directory", source);
|
||||||
readdirSync(source).forEach(file => {
|
for (let file of readdirSync(source)) {
|
||||||
if (statSync(join(source, file)).isDirectory()) {
|
if (statSync(join(source, file)).isDirectory()) {
|
||||||
filewalker(join(source, file));
|
await filewalker(join(source, file));
|
||||||
} else {
|
} else {
|
||||||
console.debug("processing file", join(source, file))
|
console.debug("processing file", join(source, file))
|
||||||
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}));
|
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 = {
|
let targetSource = {
|
||||||
_id: id,
|
_id: id,
|
||||||
|
|
@ -82,13 +82,11 @@ const convert = async function (from, to, ofType, overwrite = true) {
|
||||||
let target = JSON.stringify(targetSource, null, 2);
|
let target = JSON.stringify(targetSource, null, 2);
|
||||||
let newFileName = "./" + join(DEST, id + ".json");
|
let newFileName = "./" + join(DEST, id + ".json");
|
||||||
writeFileSync(newFileName, target, {encoding: "utf8"});
|
writeFileSync(newFileName, target, {encoding: "utf8"});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filewalker(SOURCE)
|
return await filewalker(SOURCE)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanDist() {
|
function cleanDist() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue