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

Commit

Permalink
refactor(utils): move userLeftMsgEmpty to utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Garant committed Nov 4, 2019
1 parent caea2c7 commit 6892014
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
17 changes: 1 addition & 16 deletions src/cmds/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { isArray } from 'lodash'
import { produce } from 'immer'
import { openUrl, userRanValidFlags, openFileInEditor } from '../utils'
import { openUrl, userRanValidFlags, openFileInEditor, userLeftMsgEmpty } from '../utils'
import * as base from '../base'
import { afterHooks, beforeHooks } from '../hooks'
import * as logger from '../logger'
Expand Down Expand Up @@ -344,21 +344,6 @@ async function listFromAllRepositories(options) {
}
}

/**
* Checks if string has been merged with a common flag or is empty
*/
function userLeftMsgEmpty(string: string): boolean {
return (
string === '' ||
string === '--title' ||
string === '-t' ||
string === '--message' ||
string === '-m' ||
string === '--comment' ||
string === '-c'
)
}

function newIssue(options) {
options = produce(options, draft => {
if (draft.labels) {
Expand Down
17 changes: 17 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ export function openUrl(url) {
testing ? console.log(url) : open(url, { wait: false })
}

/**
* Checks if string has been merged with a common flag or is empty
*/
export function userLeftMsgEmpty(string: string): boolean {
return (
string === '' ||
string === '--title' ||
string === '-t' ||
string === '--message' ||
string === '-m' ||
string === '--comment' ||
string === '-c' ||
string === '--description' ||
string === '-D'
)
}

/**
* Allows users to add text from their editor of choice rather than the terminal
*
Expand Down

0 comments on commit 6892014

Please sign in to comment.