diff --git a/apps/server/compile.ts b/apps/server/compile.ts index 55b3e10..b5bdb93 100644 --- a/apps/server/compile.ts +++ b/apps/server/compile.ts @@ -1,5 +1,5 @@ import { rm } from 'node:fs/promises' -import process from 'node:process' +import { parseArgs } from 'node:util' const ENTRYPOINT = '.output/server/index.mjs' const OUTDIR = 'out' @@ -23,16 +23,20 @@ const HOST_MAP: Record = { 'linux-arm64': 'bun-linux-arm64', } +const { values } = parseArgs({ + options: { target: { type: 'string' } }, + strict: true, + allowPositionals: false, +}) + const resolveTarget = (): Target => { - const idx = process.argv.indexOf('--target') - if (idx !== -1) { - const value = process.argv[idx + 1] - if (!isTarget(value)) { + if (values.target !== undefined) { + if (!isTarget(values.target)) { throw new Error( - `Invalid target: ${value}\nAllowed: ${Object.keys(TARGETS).join(', ')}`, + `Invalid target: ${values.target}\nAllowed: ${Object.keys(TARGETS).join(', ')}`, ) } - return value + return values.target } const key = `${process.platform}-${process.arch}`