From e7257b505785fc5cb612fcc36be740f9e8c52912 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Wed, 9 Jul 2025 09:15:31 -0700 Subject: [PATCH] fix: move cli entrypoint to separate file (#153) --- package.json | 4 ++-- src/cli.ts | 13 +++++++++++++ src/index.ts | 12 ------------ 3 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 src/cli.ts diff --git a/package.json b/package.json index b23820d..02f6797 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "type": "module", "exports": "./dist/index.js", "bin": { - "fiddle-core": "dist/index.js" + "fiddle-core": "dist/cli.js" }, "files": [ "dist", @@ -30,7 +30,7 @@ "lint:prettier:fix": "prettier --write package.json src/**/*.ts tests/**/*.ts", "make": "run-p build", "prepublishOnly": "npm run make", - "start": "node dist/index.js", + "start": "node dist/cli.js", "test": "vitest run", "test:ci": "vitest run --coverage" }, diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..9b83215 --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,13 @@ +#!/usr/bin/env node + +import * as fs from 'node:fs'; +import { fileURLToPath } from 'node:url'; + +import { runFromCommandLine } from './command-line.js'; + +if ( + (await fs.promises.realpath(process.argv[1])) === + fileURLToPath(import.meta.url) +) { + void runFromCommandLine(process.argv.slice(2)); +} diff --git a/src/index.ts b/src/index.ts index 372cadd..646c91e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,3 @@ -#!/usr/bin/env node - -import * as fs from 'node:fs'; -import { fileURLToPath } from 'node:url'; - import { DefaultPaths, Paths } from './paths.js'; import { ElectronBinary, @@ -67,10 +62,3 @@ export { compareVersions, runFromCommandLine, }; - -if ( - (await fs.promises.realpath(process.argv[1])) === - fileURLToPath(import.meta.url) -) { - void runFromCommandLine(process.argv.slice(2)); -}