Skip to content

Commit

Permalink
another test to be sure
Browse files Browse the repository at this point in the history
  • Loading branch information
conmaster2112 committed Oct 4, 2024
1 parent af61036 commit 8f79d8f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/flags/data/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolve } from "node:path";
import { FileTree } from "../../functions.js";
import { readFile, writeFile } from "node:fs/promises";
import { DATA_OUTPUT_FOLDER } from "./consts.js";
import { existsSync, mkdirSync } from "node:fs";

const OUTPUT_BLOCK_STATES = "block_states.json";
const OUTPUT_BLOCKS = "blocks.json";
Expand Down Expand Up @@ -59,10 +60,11 @@ async function Task(input, fileName) {
return e;
});

if(!existsSync(DATA_OUTPUT_FOLDER)) mkdirSync(DATA_OUTPUT_FOLDER, {recursive:true});

console.log("[DATA/BLOCKS_STATES] Generated: " + OUTPUT_BLOCK_STATES);
let results = await writeFile(resolve(DATA_OUTPUT_FOLDER, OUTPUT_BLOCK_STATES), JSON.stringify(states, null, 3)).then(()=>true, ()=>false);
if(!results) return false;
console.log("[DATA/BLOCKS_STATES] Generated: " + OUTPUT_BLOCK_STATES);

// @ts-ignore
const blocks = data["data_items"].map((e)=>{
Expand All @@ -71,9 +73,9 @@ async function Task(input, fileName) {
return MapBlock(states_map, e);
});

console.log("[DATA/BLOCKS] Generated: " + OUTPUT_BLOCKS);
results = await writeFile(resolve(DATA_OUTPUT_FOLDER, OUTPUT_BLOCKS), JSON.stringify(blocks, null, 3)).then(()=>true, ()=>false);
if(!results) return false;
console.log("[DATA/BLOCKS] Generated: " + OUTPUT_BLOCKS);

// Returns if file was successfully created
return true;
Expand Down

0 comments on commit 8f79d8f

Please sign in to comment.