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()) {
|
||||
await filewalker(join(source, file))
|
||||
} else {
|
||||
console.debug("processing file", join(source, file))
|
||||
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}))
|
||||
promises.push(new Promise((resolve2) => {
|
||||
randomID("DSA_4-1" + TYPE + originalSource.name.trim()).then(id => {
|
||||
let targetSource = {
|
||||
_id: id,
|
||||
_key: "!items!" + id,
|
||||
type: TYPE,
|
||||
img: originalSource.image,
|
||||
name: originalSource.name.trim(),
|
||||
system: {...originalSource},
|
||||
}
|
||||
delete targetSource.system.image;
|
||||
let target = JSON.stringify(targetSource, null, 2)
|
||||
let newFileName = "./" + join(DEST, id + ".json")
|
||||
if (!existsSync(join("./", DEST))) {
|
||||
mkdirSync(join("./", DEST))
|
||||
}
|
||||
writeFileSync(newFileName, target, {encoding: "utf8"})
|
||||
resolve2()
|
||||
})
|
||||
if (file.endsWith(".json")) {
|
||||
console.debug("processing file", join(source, file))
|
||||
let originalSource = JSON.parse(readFileSync(join(source, file), {encoding: "utf8"}))
|
||||
promises.push(new Promise((resolve2) => {
|
||||
randomID("DSA_4-1" + TYPE + originalSource.name.trim()).then(id => {
|
||||
let targetSource = {
|
||||
_id: id,
|
||||
_key: "!items!" + id,
|
||||
type: TYPE,
|
||||
img: originalSource.image,
|
||||
name: originalSource.name.trim(),
|
||||
system: {...originalSource},
|
||||
}
|
||||
delete targetSource.system.image;
|
||||
let target = JSON.stringify(targetSource, null, 2)
|
||||
let newFileName = "./" + join(DEST, id + ".json")
|
||||
if (!existsSync(join("./", DEST))) {
|
||||
mkdirSync(join("./", DEST))
|
||||
}
|
||||
writeFileSync(newFileName, target, {encoding: "utf8"})
|
||||
resolve2()
|
||||
})
|
||||
|
||||
}))
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue