UNPKG

@worldapi/cli

Version:

A productivity focused CLI and terminal for WorldAPI.

20 lines (19 loc) 704 B
import fs from "fs/promises"; import parseDirectory from "../../functions/fs/parseDirectory.js"; async function create(json, options) { try { if (options.createDir && options.createDir !== ".") await fs.mkdir(options.createDir, { recursive: true }); const _json = await fs.readFile(json, "utf-8"); const mappings = JSON.parse(_json); if (mappings.constructor !== Object) console.log("[World API]: Invalid JSON file. Please make sure the JSON file is an object."); await parseDirectory(mappings, options.createDir || "./"); } catch (error) { console.error("[World API]: Error while creating mappings"); console.log(error); } } export { create as default };