#!/usr/bin/env node import { build, postBuild } from '../build' const command = process.argv[2] if (command !== 'build') printHelp() const args = parseArgs() if (Object.keys(args).includes('--help')) printHelp() build().catch((err: any) => { console.error(err) process.exit(1) }) postBuild().catch((err: any) => { console.error(err) process.exit(1) }) function parseArgs() { return process.argv.slice(2).reduce((acc, key, ind, self) => { if (key.startsWith('--')) { if (self[ind + 1] && self[ind + 1].startsWith('-')) { acc[key] = undefined } else if (self[ind + 1]) { acc[key] = self[ind + 1] } else if (!self[ind + 1]) { acc[key] = undefined } } return acc }, {} as Record) } function printHelp() { console.log('Unknown command') console.log('') console.log('Usage:') console.log(' npx ampt-next build') console.log('') process.exit(1) }