From 910eaca698faee8d1cb079168e157bf5f4647268 Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Sun, 14 Apr 2024 10:07:27 -0400 Subject: [PATCH] add --bun option and document bunx --bun --- README.md | 3 ++- gdf.js | 5 +++-- index.js | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d755b0a..f593687 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ To run once: ``` npx --yes @flydotio/dockerfile@latest +bunx --bun @flydotio/dockerfile@latest ``` Or install it with your favorite package manager: @@ -23,7 +24,7 @@ pnpm add -D @flydotio/dockerfile yarn add @flydotio/dockerfile --dev ``` -Once installed, you can run and re-run using `npx dockerfile` for Node.js applications or `bunx dockerfile` for Bun applications. +Once installed, you can run and re-run using `npx dockerfile` for Node.js applications or `bunx --bun dockerfile` for Bun applications. Options are saved between runs into `package.json`. To invert a boolean options, add or remove a no- prefix from the option name. diff --git a/gdf.js b/gdf.js index 3e95919..9d85b4e 100755 --- a/gdf.js +++ b/gdf.js @@ -12,6 +12,7 @@ import * as ShellQuote from 'shell-quote' // defaults for all the flags that will be saved export const defaults = { alpine: false, + bun: false, build: '', cache: false, cmd: '', @@ -637,7 +638,7 @@ export class GDF { // Is the packager bun? get bun() { - return this.packager === 'bun' + return this.options.bun || this.packager === 'bun' } // How to install python (switched from buster to bullseye) @@ -740,7 +741,7 @@ export class GDF { } else if (this.#pj.main) { return [this.packager === 'bun' ? 'bun' : 'node', this.#pj.main] } else if (this.svelte) { - return ['bun', './build/index.js'] + return [this.bun ? 'bun' : 'node', './build/index.js'] } else if (this.packager === 'bun') { return ['bun', 'index.ts'] } else { diff --git a/index.js b/index.js index 7782017..c296649 100755 --- a/index.js +++ b/index.js @@ -28,6 +28,10 @@ const options = yargs((hideBin(process.argv))) describe: 'if set to "defer" will run build at deploy time', type: 'string' }) + .option('bun', { + describe: 'use bun instead of node', + type: 'boolean' + }) .option('cmd', { describe: 'CMD to be used in the Dockerfile', type: 'string'