Skip to content

Commit

Permalink
Use name and id instead of number for json names
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanistzed committed May 30, 2021
1 parent 53f708e commit 31d0609
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions extract.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ subDirs.forEach((dir, index) => {

var readPath = [worldPath, subDirs[index], db].join("/") // get the path of all the original db files


var counter = 0; // give all files a unique "id"

// Read each line one at a time and copy the contents to a json file
lineReader.eachLine(readPath, line => {
var writePath = [subDirPath, counter].join("/") + ".json"; // get path of json file to copy to
var object = JSON.parse(line);
var id = [object._id, object.name].filter(Boolean).join("-");
var writePath = [subDirPath, id].join("/") + ".json"; // get path of json file to copy to
fs.writeFileSync(writePath, line); // write the current line to that file
counter++;
});
})
});
});

0 comments on commit 31d0609

Please sign in to comment.