From 88772256da4ee909806b8f261cf1f2368c3960b7 Mon Sep 17 00:00:00 2001 From: PramaYudhistira Date: Fri, 18 Apr 2025 05:46:01 -0400 Subject: [PATCH] unify CLI launcher under Node shebang stub for cross-platform support --- codex-cli/bin/codex.js | 24 ++++++++++++++++++++++++ codex-cli/package.json | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 codex-cli/bin/codex.js diff --git a/codex-cli/bin/codex.js b/codex-cli/bin/codex.js new file mode 100644 index 000000000000..347dc854ec2c --- /dev/null +++ b/codex-cli/bin/codex.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node +// Unified entry point for Codex CLI on all platforms +// Dynamically loads the compiled ESM bundle in dist/cli.js + +import path from 'path'; +import { fileURLToPath, pathToFileURL } from 'url'; + +// Determine this script's directory +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); + +// Resolve the path to the compiled CLI bundle +const cliPath = path.resolve(__dirname, '../dist/cli.js'); +const cliUrl = pathToFileURL(cliPath).href; + +// Load and execute the CLI +(async () => { + try { + await import(cliUrl); + } catch (err) { + console.error(err); + process.exit(1); + } +})(); diff --git a/codex-cli/package.json b/codex-cli/package.json index f5722a1351d1..6834f15694f9 100644 --- a/codex-cli/package.json +++ b/codex-cli/package.json @@ -3,7 +3,7 @@ "version": "0.1.2504172351", "license": "Apache-2.0", "bin": { - "codex": "bin/codex" + "codex": "bin/codex.js" }, "type": "module", "engines": {