UNPKG

node-serum2-preset-packager

Version:
24 lines (22 loc) 697 B
import { basename } from 'node:path'; import { unpack, pack } from './index.mjs'; import 'node:fs/promises'; import 'cbor2'; import '@mongodb-js/zstd'; async function usage(exitCode = 0) { const prog = basename(process.argv[1]); console.log(`usage: ${prog} unpack <file.SerumPreset> <out.json>`); console.log(` ${prog} pack <in.json> <out.SerumPreset>`); process.exit(exitCode); } (async () => { const [, , cmd, src, dst] = process.argv; if (!cmd || !src || !dst || !["unpack", "pack"].includes(cmd)) usage(1); try { ; (cmd === "unpack" ? await unpack : await pack)(src, dst); } catch (err) { console.error(err.message); process.exit(2); } })();