From 85477ea60f747578250eac73792d8a57fa2efe20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 11 Feb 2025 23:08:22 +0800 Subject: [PATCH] feat: respect `EDITOR` environment variable --- src/config.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index cdeceb6..caebf99 100644 --- a/src/config.ts +++ b/src/config.ts @@ -163,7 +163,10 @@ export default config } export async function editConfig(filePath: string): Promise { - if (await cmdExists('code')) { + const EDITOR = process.env.EDITOR + if (EDITOR && (await cmdExists(EDITOR))) { + await x(EDITOR, [filePath], { nodeOptions: { stdio: 'inherit' } }) + } else if (await cmdExists('code')) { await x('code', [filePath]) } else if (await cmdExists('zed')) { await x('zed', [filePath], { nodeOptions: { stdio: 'inherit' } }) @@ -171,7 +174,7 @@ export async function editConfig(filePath: string): Promise { await x('vim', [filePath], { nodeOptions: { stdio: 'inherit' } }) } else { consola.info( - `VSCode and Vim are not detected, please open and edit config file manually: ${filePath}`, + `Editors are not detected, please open and edit config file manually: ${filePath}`, ) } } -- knotmirror 0.0.1