From be7e5b0cfac4f6b1db7915a809ead44f1150f5bd Mon Sep 17 00:00:00 2001 From: Ryan Garant Date: Tue, 5 Nov 2019 13:04:44 -0800 Subject: [PATCH] feat(issue): dont open editor when use_editor is false --- .vscode/launch.json | 10 +--------- src/cmds/issue.ts | 10 +++++++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 00b4a9cf..cedfb1b3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,15 +9,7 @@ "type": "node", "request": "launch", "runtimeArgs": ["-r", "ts-node/register"], - "args": [ - "${workspaceFolder}/src/debug.ts", - "pr", - "-s", - "protoEvangleion", - "--title", - "dont ask", - "--description" - ], + "args": ["${workspaceFolder}/src/debug.ts", "is", "--new"], // "args": ["${workspaceFolder}/src/debug.ts", "ji", "LWM-117", "--status"], "console": "integratedTerminal" }, diff --git a/src/cmds/issue.ts b/src/cmds/issue.ts index f57c4aeb..dc62fef3 100644 --- a/src/cmds/issue.ts +++ b/src/cmds/issue.ts @@ -226,9 +226,11 @@ function browser(user, repo, number) { } function comment(options) { + const useEditor = options.config.use_editor !== false + let body = logger.applyReplacements(options.comment, config.replace) + config.signature - if (userLeftMsgEmpty(options.comment)) { + if (useEditor && userLeftMsgEmpty(options.comment)) { body = openFileInEditor( 'temp-gh-issue-comment.md', '' @@ -346,6 +348,8 @@ async function listFromAllRepositories(options) { function newIssue(options) { options = produce(options, draft => { + const useEditor = draft.config.use_editor !== false + if (draft.labels) { draft.labels = draft.labels.split(',') } else { @@ -356,7 +360,7 @@ function newIssue(options) { draft.message = logger.applyReplacements(draft.message, config.replace) } - if (userLeftMsgEmpty(draft.title)) { + if (useEditor && userLeftMsgEmpty(draft.title)) { draft.title = openFileInEditor( 'temp-gh-issue-title.txt', '# Add a issue title message on the next line' @@ -365,7 +369,7 @@ function newIssue(options) { // If user passes an empty title and message, --message will get merged into options.title // Need to reference the original title not the potentially modified one - if (userLeftMsgEmpty(options.title) || userLeftMsgEmpty(draft.message)) { + if (useEditor && (userLeftMsgEmpty(options.title) || userLeftMsgEmpty(draft.message))) { draft.message = openFileInEditor( 'temp-gh-issue-body.md', ''