2023-05-14 11:52:47 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
import { build, context } from 'esbuild'
|
|
|
|
import pkg from '../package.json' assert { type: 'json' }
|
|
|
|
|
|
|
|
const options = {
|
2024-03-03 00:22:39 +00:00
|
|
|
entryPoints: ['./src/cli.ts'],
|
2023-05-14 11:52:47 +00:00
|
|
|
bundle: true,
|
|
|
|
minify: true,
|
|
|
|
platform: 'node',
|
2024-03-03 00:22:39 +00:00
|
|
|
outfile: './dist/cli.cjs',
|
2023-05-14 11:52:47 +00:00
|
|
|
define: { VERSION: `"${pkg.version}"` },
|
|
|
|
}
|
|
|
|
|
|
|
|
const watch = process.argv.slice(2)[0] === '--watch'
|
2024-03-03 00:22:39 +00:00
|
|
|
if (watch) {
|
|
|
|
;(await context(options)).watch()
|
|
|
|
} else {
|
|
|
|
await build(options)
|
|
|
|
|
|
|
|
// Also build internals to expose
|
|
|
|
await build({
|
|
|
|
entryPoints: ['./src/index.ts'],
|
|
|
|
bundle: true,
|
|
|
|
minify: true,
|
|
|
|
platform: 'node',
|
|
|
|
format: 'esm',
|
|
|
|
outfile: './dist/index.js',
|
|
|
|
define: { VERSION: `"${pkg.version}"` },
|
|
|
|
})
|
|
|
|
}
|