UNPKG

@worldapi/cli

Version:

A productivity focused CLI and terminal for WorldAPI.

20 lines (19 loc) 690 B
import glob from "glob-promise"; import create from "../../functions/template/create.js"; import fs from "fs/promises"; async function export_default(dir, options) { try { let files = await glob(`${dir}/**/*`, { nodir: true }); files = files.filter((str) => !str.includes("node_modules")); files = files.map((str) => str.slice(dir.length)); const template = create(files); if (options.out) return await fs.writeFile(options.out, JSON.stringify(template, null, 2)); await fs.writeFile("template.json", JSON.stringify(template, null, 2)); } catch (error) { console.error("[World API]: Exporting fs failed"); } } export { export_default as default };