parent
373781b5b0
commit
db81e2def1
46
gulpfile.mjs
46
gulpfile.mjs
|
|
@ -68,29 +68,31 @@ const convert = function (from, to, ofType, overwrite = true) {
|
||||||
if (statSync(join(source, file)).isDirectory()) {
|
if (statSync(join(source, file)).isDirectory()) {
|
||||||
await filewalker(join(source, file))
|
await filewalker(join(source, file))
|
||||||
} else {
|
} else {
|
||||||
console.debug("processing file", join(source, file))
|
if (file.endsWith(".json")) {
|
||||||
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}))
|
console.debug("processing file", join(source, file))
|
||||||
promises.push(new Promise((resolve2) => {
|
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}))
|
||||||
randomID("DSA_4-1" + TYPE + originalSource.name.trim()).then(id => {
|
promises.push(new Promise((resolve2) => {
|
||||||
let targetSource = {
|
randomID("DSA_4-1" + TYPE + originalSource.name.trim()).then(id => {
|
||||||
_id: id,
|
let targetSource = {
|
||||||
_key: "!items!" + id,
|
_id: id,
|
||||||
type: TYPE,
|
_key: "!items!" + id,
|
||||||
img: originalSource.image,
|
type: TYPE,
|
||||||
name: originalSource.name.trim(),
|
img: originalSource.image,
|
||||||
system: {...originalSource},
|
name: originalSource.name.trim(),
|
||||||
}
|
system: {...originalSource},
|
||||||
delete targetSource.system.image;
|
}
|
||||||
let target = JSON.stringify(targetSource, null, 2)
|
delete targetSource.system.image;
|
||||||
let newFileName = "./" + join(DEST, id + ".json")
|
let target = JSON.stringify(targetSource, null, 2)
|
||||||
if (!existsSync(join("./", DEST))) {
|
let newFileName = "./" + join(DEST, id + ".json")
|
||||||
mkdirSync(join("./", DEST))
|
if (!existsSync(join("./", DEST))) {
|
||||||
}
|
mkdirSync(join("./", DEST))
|
||||||
writeFileSync(newFileName, target, {encoding: "utf8"})
|
}
|
||||||
resolve2()
|
writeFileSync(newFileName, target, {encoding: "utf8"})
|
||||||
})
|
resolve2()
|
||||||
|
})
|
||||||
|
|
||||||
}))
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue