diff --git a/package-lock.json b/package-lock.json index 0c839e49..9fc7d693 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gh", - "version": "2.8.1", + "version": "2.8.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/utils.ts b/src/utils.ts index 11dcf052..6a91e6fc 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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}"`)