Skip to content
This repository was archived by the owner on Nov 4, 2022. It is now read-only.

Commit 192e142

Browse files
Julien CastelainRyan Garant
Julien Castelain
authored and
Ryan Garant
committed
fix: check for editor in environment variables
To determine which editor to use for commit messages look if $EDITOR or $VISUAL are set in the environment before checking the git config. If no editor is found throw an error. Fixes #745
1 parent b85f5e8 commit 192e142

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,15 @@ export function openFileInEditor(fileName: string, msg: string): string {
7777

7878
writeFileSync(filePath, msg)
7979

80-
const editor = spawnSync('git', ['config', '--global', 'core.editor']).stdout
80+
const editor = process.env.EDITOR
81+
? process.env.EDITOR
82+
: process.env.VISUAL
83+
? process.env.VISUAL
84+
: spawnSync('git', ['config', '--global', 'core.editor']).stdout
85+
86+
if (!editor) {
87+
throw new Error('Could not determine which editor to use')
88+
}
8189

8290
execSyncInteractiveStream(`${editor} "${filePath}"`)
8391

0 commit comments

Comments
 (0)