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

Commit

Permalink
fix: check for editor in environment variables
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Julien Castelain authored and Ryan Garant committed Nov 25, 2019
1 parent b85f5e8 commit 192e142
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ export function openFileInEditor(fileName: string, msg: string): string {

writeFileSync(filePath, msg)

const editor = spawnSync('git', ['config', '--global', 'core.editor']).stdout
const editor = process.env.EDITOR
? process.env.EDITOR
: process.env.VISUAL
? process.env.VISUAL
: spawnSync('git', ['config', '--global', 'core.editor']).stdout

if (!editor) {
throw new Error('Could not determine which editor to use')
}

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

Expand Down

0 comments on commit 192e142

Please sign in to comment.