From 297ccac45bb09f76194cde66302ddd345c71eae1 Mon Sep 17 00:00:00 2001 From: di-sukharev Date: Mon, 6 Mar 2023 22:12:37 +0800 Subject: [PATCH] =?UTF-8?q?*=20=F0=9F=90=9B=20fix(package.json):=20change?= =?UTF-8?q?=20cli=20file=20extension=20from=20.cjs=20to=20.mjs=20*=20?= =?UTF-8?q?=F0=9F=90=9B=20fix(githook.ts):=20change=20cli=20file=20path=20?= =?UTF-8?q?to=20match=20new=20extension=20The=20cli=20file=20extension=20h?= =?UTF-8?q?as=20been=20changed=20from=20.cjs=20to=20.mjs=20to=20improve=20?= =?UTF-8?q?compatibility=20with=20Node.js=20ESM=20modules.=20The=20file=20?= =?UTF-8?q?path=20in=20githook.ts=20has=20been=20updated=20to=20match=20th?= =?UTF-8?q?e=20new=20extension.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 8 ++++---- src/commands/githook.ts | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 26e24e3..6a0ac5f 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ ], "main": "cli.js", "bin": { - "opencommit": "./out/cli.cjs", - "oc": "./out/cli.cjs" + "opencommit": "./out/cli.mjs", + "oc": "./out/cli.mjs" }, "repository": { "url": "https://github.com/di-sukharev/opencommit" @@ -34,9 +34,9 @@ }, "scripts": { "watch": "npm run -S build -- --sourcemap --watch", - "start": "node ./out/cli.cjs", + "start": "node ./out/cli.mjs", "dev": "ts-node ./src/cli.ts", - "build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.cjs --format=cjs --platform=node", + "build": "rimraf out && esbuild ./src/cli.ts --bundle --outfile=out/cli.mjs --format=esm --platform=node --banner:js=\"import {createRequire} from 'module';const require=createRequire(import.meta.url);\"", "deploy": "npm run build && npm version patch && npm publish", "lint": "eslint src --ext ts && tsc --noEmit" }, diff --git a/src/commands/githook.ts b/src/commands/githook.ts index a33a38b..6ff8467 100644 --- a/src/commands/githook.ts +++ b/src/commands/githook.ts @@ -20,9 +20,7 @@ export const hookCommand = command( parameters: [''] }, async (argv) => { - const HOOK_PATH = fileURLToPath( - new URL('../../out/cli.cjs', import.meta.url) - ); + const HOOK_PATH = fileURLToPath(new URL('cli.mjs', import.meta.url)); try { await assertGitRepo();