From 822d3a57be96218d1f82d9ef9973ee0256cf6dfd Mon Sep 17 00:00:00 2001 From: xrkffgg Date: Thu, 24 Dec 2020 16:40:07 +0800 Subject: [PATCH] fix: yml not support array (#11) * fix: yml not support array * add --- README.md | 42 +++++++++++++++++-------------- README.zh-CN.md | 42 +++++++++++++++++-------------- dist/index.js | 67 +++++++++++++++++++++---------------------------- src/advanced.js | 10 +------- src/base.js | 46 ++++++++++++++++----------------- src/util.js | 11 ++++---- 6 files changed, 102 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index 986b0fc..8e0569a 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ jobs: actions: 'add-assignees' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} - assignees: 'xxx' or ['xxx'] or ['xx1', 'xx2'] + assignees: 'xxx' or 'xx1,xx2' ``` | Param | Desc | Type | Required | Version | @@ -73,12 +73,13 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | issue-number | The number of issue | number | ✔ | v1 | -| assignees | Designated person. No operation when no input or empty character or empty array | string \| string\[] | ✖ | v1 | +| assignees | Designated person. No operation when no input or empty character | string | ✖ | v1 | - `actions` support multiple and separated by comma. Like: `add-assignees,add-labels` - The `name` can be modified according to the actual situation - [on reference](#github-docs) - `${{ github.event.issue.number }}` is the current issue. [More references](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events) +- `assignees` support multiple and separated by comma. Pay attention to multiple settings, you need to use the version above v1.1 ⏫ [Back to list](#List) @@ -104,7 +105,7 @@ jobs: actions: 'add-labels' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} - labels: 'bug' or ['bug'] or ['bug1', 'bug2'] + labels: 'bug' or 'xx1,xx2' ``` | Param | Desc | Type | Required | Version | @@ -112,7 +113,9 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | issue-number | The number of issue | number | ✔ | v1 | -| labels | New labels. When it is not filled in or is empty character, empty array, do not add | string \| string\[] | ✖ | v1 | +| labels | New labels. When it is not filled in or is empty character, do not add | string | ✖ | v1 | + +- `labels` support multiple and separated by comma. Pay attention to multiple settings, you need to use the version above v1.1 ⏫ [Back to list](#List) @@ -164,7 +167,7 @@ jobs: Hello @${{ github.event.issue.user.login }}. Add some comments. 你好 @${{ github.event.issue.user.login }}。巴拉巴拉。 - contents: '+1' or ['+1', 'heart'] + contents: '+1' or '+1,heart' ``` | Param | Desc | Type | Required | Version | @@ -173,12 +176,13 @@ jobs: | token | [Token explain](#token) | string | ✔ | v1 | | issue-number | The number of issue | number | ✔ | v1 | | body | Add comment content | string | ✖ | v1 | -| contents | Add [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| contents | Add [reaction](#reactions-types) | string | ✖ | v1 | - `body` default is `Currently at ${owner}/${repo}. And this is default comment.` - Where `${owner}/${repo}` means the current repo - Return `comment-id`, which can be used for subsequent operations. [Usage reference](#outputs-use) - `${{ github.event.issue.user.login }}` indicates the creator of the issue +- `contents` support multiple and separated by comma. Pay attention to multiple settings, you need to use the version above v1.1 ⏫ [Back to list](#List) @@ -215,9 +219,9 @@ jobs: | token | [Token explain](#token) | string | ✔ | v1 | | title | The title of the new issue | string | ✖ | v1 | | body | The body of the new issue | string | ✖ | v1 | -| labels | The labels for the new issue | string \| string\[] | ✖ | v1 | -| assignees | The assignees for the new issue | string \| string\[] | ✖ | v1 | -| contents | Add [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| labels | The labels for the new issue | string | ✖ | v1 | +| assignees | The assignees for the new issue | string | ✖ | v1 | +| contents | Add [reaction](#reactions-types) | string | ✖ | v1 | - `title` default is `Default Title` - Return `issue-number`. [Usage reference](#outputs-use) @@ -317,7 +321,7 @@ Remove the person designated by issue. | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | issue-number | The number of issue | number | ✔ | v1 | -| assignees | Designated person removed. When it is an empty character, empty array, do not remove | string \| string\[] | ✔ | v1 | +| assignees | Designated person removed. When it is an empty character, do not remove | string | ✔ | v1 | ⏫ [Back to list](#List) @@ -340,7 +344,7 @@ Replace the labels of issue. | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | issue-number | The number of issue | number | ✔ | v1 | -| labels | labels set. When empty characters, empty array, will remove all | string \| string\[] | ✔ | v1 | +| labels | labels set. When empty characters, will remove all | string | ✔ | v1 | ⏫ [Back to list](#List) @@ -398,7 +402,7 @@ jobs: | comment-id | The comment ID | number | ✔ | v1 | | body | Update the content of comment | string | ✖ | v1 | | update-mode | Update mode. Default `replace`, another `append` | string | ✖ | v1 | -| contents | Add [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| contents | Add [reaction](#reactions-types) | string | ✖ | v1 | - When `body` is not entered, it will remain as it is - When `update-mode` is `append`, additional operations will be performed. Anything other than `append` will be replaced. Only effective for `body` @@ -434,9 +438,9 @@ Update the specified issue according to the `issue-number`. | title | Modify the title of the issue | string | ✖ | v1 | | body | Modify the content of issue | string | ✖ | v1 | | update-mode | Update mode. Default `replace`, another `append` | string | ✖ | v1 | -| labels | Replace the labels of issue | string \| string\[] | ✖ | v1 | -| assignees | Replace the assignees of issue | string \| string\[] | ✖ | v1 | -| contents | Add [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| labels | Replace the labels of issue | string | ✖ | v1 | +| assignees | Replace the assignees of issue | string | ✖ | v1 | +| contents | Add [reaction](#reactions-types) | string | ✖ | v1 | - `state` defaults to `open` - When the option is not filled, it will keep the original @@ -475,7 +479,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | -| labels | Labels filtering | string \| string\[] | ✖ | v1 | +| labels | Labels filtering | string | ✖ | v1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | | issue-creator | Creator filtering | string | ✖ | v1 | @@ -520,7 +524,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | -| labels | Labels filtering | string \| string\[] | ✖ | v1 | +| labels | Labels filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | | issue-creator | Creator filtering | string | ✖ | v1 | | issue-mentioned | Mentioned filtering | string | ✖ | v1 | @@ -601,7 +605,7 @@ jobs: | actions | Action type | string | ✔ | v1 | | token | [Token explain](#token) | string | ✔ | v1 | | body | When operating an issue, you can comment. Do not comment when not typing | string | ✖ | v1 | -| labels | Labels filtering | string \| string\[] | ✖ | v1 | +| labels | Labels filtering | string | ✖ | v1 | | issue-state | State filtering | string | ✖ | v1 | | issue-assignee | Assignee filtering | string | ✖ | v1 | | issue-creator | Creator filtering | string | ✖ | v1 | @@ -756,7 +760,7 @@ You can come to the following repositories for reference. Please leave a message
- Vue Request + vue-request diff --git a/README.zh-CN.md b/README.zh-CN.md index dc8fd88..e8adf20 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -65,7 +65,7 @@ jobs: actions: 'add-assignees' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} - assignees: 'xxx' or ['xxx'] or ['xx1', 'xx2'] + assignees: 'xxx' or 'xx1,xx2' ``` | 参数 | 描述 | 类型 | 必填 | 版本 | @@ -73,12 +73,13 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | issue-number | 指定的 issue | number | ✔ | v1 | -| assignees | 指定人。当不填或者为空字符、空数组时,不操作 | string \| string\[] | ✖ | v1 | +| assignees | 指定人。当不填或者为空字符时,不操作 | string | ✖ | v1 | - `actions` 支持多个,需用逗号隔开。如:`add-assignees,add-labels` - 其中的 `name` 可根据自行根据实际情况修改 - [on 参考](#github-docs) - `${{ github.event.issue.number }}` 表示当前 issue,[更多参考](https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events) +- `assignees` 支持多个,需用逗号隔开。注意设置多个,需使用v1.1以上版本 ⏫ [返回列表](#列-表) @@ -104,7 +105,7 @@ jobs: actions: 'add-labels' token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.issue.number }} - labels: 'bug' or ['bug'] or ['bug1', 'bug2'] + labels: 'bug' or 'bug1,bug2' ``` | 参数 | 描述 | 类型 | 必填 | 版本 | @@ -112,7 +113,9 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | issue-number | 指定的 issue | number | ✔ | v1 | -| labels | 新增的 labels。当不填或者为空字符、空数组时,不新增 | string \| string\[] | ✖ | v1 | +| labels | 新增的 labels。当不填或者为空字符时,不新增 | string | ✖ | v1 | + +- `labels` 支持多个,需用逗号隔开。注意设置多个,需使用v1.1以上版本 ⏫ [返回列表](#列-表) @@ -164,7 +167,7 @@ jobs: Hello ${{ github.event.issue.user.login }}. Add some comments. 你好 ${{ github.event.issue.user.login }}。巴拉巴拉。 - contents: '+1' or ['+1', 'heart'] + contents: '+1' or '+1,heart' ``` | 参数 | 描述 | 类型 | 必填 | 版本 | @@ -173,12 +176,13 @@ jobs: | token | [token 说明](#token) | string | ✔ | v1 | | issue-number | 指定的 issue | number | ✔ | v1 | | body | 新增评论的内容 | string | ✖ | v1 | -| contents | 为新增评论的增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| contents | 为新增评论的增加 [reaction](#reactions-types) | string | ✖ | v1 | - `body` 默认为:`Currently at ${owner}/${repo}. And this is default comment.` - 其中 `${owner}/${repo}` 表示当前仓库 - 返回 `comment-id`,可用于之后操作。[用法参考](#outputs-使用) - `${{ github.event.issue.user.login }}` 表示该 issue 的创建者 +- `contents` 支持多个,需用逗号隔开。注意设置多个,需使用v1.1以上版本 ⏫ [返回列表](#列-表) @@ -215,9 +219,9 @@ jobs: | token | [token 说明](#token) | string | ✔ | v1 | | title | 新增 issue 的标题 | string | ✖ | v1 | | body | 新增 issue 的内容 | string | ✖ | v1 | -| labels | 为新增 issue 添加 labels | string \| string\[] | ✖ | v1 | -| assignees | 为新增 issue 添加 assignees | string \| string\[] | ✖ | v1 | -| contents | 为新增 issue 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| labels | 为新增 issue 添加 labels | string | ✖ | v1 | +| assignees | 为新增 issue 添加 assignees | string | ✖ | v1 | +| contents | 为新增 issue 增加 [reaction](#reactions-types) | string | ✖ | v1 | - `title` 默认为:`Default Title` - 返回 `issue-number`,[用法参考](#outputs-使用) @@ -317,7 +321,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | issue-number | 指定的 issue | number | ✔ | v1 | -| assignees | 移除的指定人。当为空字符、空数组时,不进行移除 | string \| string\[] | ✔ | v1 | +| assignees | 移除的指定人。当为空字符时,不进行移除 | string | ✔ | v1 | ⏫ [返回列表](#列-表) @@ -340,7 +344,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | issue-number | 指定的 issue | number | ✔ | v1 | -| labels | labels 设置。当空字符、空数组时,会移除所有 | string \| string\[] | ✔ | v1 | +| labels | labels 设置。当空字符时,会移除所有 | string | ✔ | v1 | ⏫ [返回列表](#列-表) @@ -398,7 +402,7 @@ jobs: | comment-id | 指定的 comment | number | ✔ | v1 | | body | 更新 comment 的内容 | string | ✖ | v1 | | update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ | v1 | -| contents | 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| contents | 增加 [reaction](#reactions-types) | string | ✖ | v1 | - `body` 不填时,会保持原有 - `update-mode` 为 `append` 时,会进行附加操作。非 `append` 都会进行替换。仅对 `body` 生效 @@ -434,9 +438,9 @@ jobs: | title | 修改 issue 的标题 | string | ✖ | v1 | | body | 修改 issue 的内容 | string | ✖ | v1 | | update-mode | 更新模式。默认 `replace` 替换,`append` 附加 | string | ✖ | v1 | -| labels | 替换 issue 的 labels | string \| string\[] | ✖ | v1 | -| assignees | 替换 issue 的 assignees | string \| string\[] | ✖ | v1 | -| contents | 增加 [reaction](#reactions-types) | string \| string\[] | ✖ | v1 | +| labels | 替换 issue 的 labels | string | ✖ | v1 | +| assignees | 替换 issue 的 assignees | string | ✖ | v1 | +| contents | 增加 [reaction](#reactions-types) | string | ✖ | v1 | - `state` 默认为 `open` - 当可选项不填时,会保持原有 @@ -475,7 +479,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | -| labels | 标签筛选 | string \| string\[] | ✖ | v1 | +| labels | 标签筛选 | string | ✖ | v1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | | issue-creator | 创建人筛选 | string | ✖ | v1 | @@ -520,7 +524,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | -| labels | 标签筛选 | string \| string\[] | ✖ | v1 | +| labels | 标签筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | | issue-creator | 创建人筛选 | string | ✖ | v1 | | issue-mentioned | 提及人筛选 | string | ✖ | v1 | @@ -601,7 +605,7 @@ jobs: | actions | 操作类型 | string | ✔ | v1 | | token | [token 说明](#token) | string | ✔ | v1 | | body | 操作 issue 时,可进行评论。不填时,不评论 | string | ✖ | v1 | -| labels | 标签筛选 | string \| string\[] | ✖ | v1 | +| labels | 标签筛选 | string | ✖ | v1 | | issue-state | 状态筛选 | string | ✖ | v1 | | issue-assignee | 指定人筛选 | string | ✖ | v1 | | issue-creator | 创建人筛选 | string | ✖ | v1 | @@ -756,7 +760,7 @@ jobs:
- Vue Request + vue-request diff --git a/dist/index.js b/dist/index.js index ebed05f..b4b02c3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -6107,15 +6107,7 @@ async function doQueryIssues (owner, repo, labels, state) { issueMentioned ? params.mentioned = issueMentioned : null; if (labels) { - if (typeof(labels) === 'string') { - params.labels = labels; - } else { - let temp = ''; - labels.forEach((it,index) => { - index == labels.length - 1 ? temp += `${it}` : temp += `${it},`; - }); - params.labels = temp; - } + params.labels = labels; } const res = await octokit.issues.listForRepo(params); @@ -6215,12 +6207,12 @@ async function doCreateComment (owner, repo, issueNumber, body) { core.setOutput("comment-id", data.id); if (contents) { - await doCreateCommentContent(owner, repo, data.id, contents); + await doCreateCommentContent(owner, repo, data.id, dealInput(contents)); } }; -async function doCreateCommentContent(owner, repo, commentId) { - if (typeof(contents) === 'object') { +async function doCreateCommentContent(owner, repo, commentId, contents) { + if (contents.length) { contents.forEach(async item => { if (testContent(item)) { await octokit.reactions.createForIssueComment({ @@ -6232,14 +6224,6 @@ async function doCreateCommentContent(owner, repo, commentId) { core.info(`Actions: [create-reactions][${item}] success!`); } }) - } else if (typeof(contents) === 'string' && testContent(contents)) { - await octokit.reactions.createForIssueComment({ - owner, - repo, - comment_id: commentId, - content: contents - }); - core.info(`Actions: [create-reactions][${contents}] success!`); } }; @@ -6258,12 +6242,12 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) { core.setOutput("issue-number", data.number); if (contents) { - await doCreateIssueContent(owner, repo, data.number, contents); + await doCreateIssueContent(owner, repo, data.number, dealInput(contents)); } }; -async function doCreateIssueContent(owner, repo, issueNumber) { - if (typeof(contents) === 'object') { +async function doCreateIssueContent(owner, repo, issueNumber, contents) { + if (contents.length) { contents.forEach(async item => { if (testContent(item)) { await octokit.reactions.createForIssue({ @@ -6275,14 +6259,6 @@ async function doCreateIssueContent(owner, repo, issueNumber) { core.info(`Actions: [create-reactions][${item}] success!`); } }) - } else if (typeof(contents) === 'string' && testContent(contents)) { - await octokit.reactions.createForIssue({ - owner, - repo, - issue_number: issueNumber, - content: contents - }); - core.info(`Actions: [create-reactions][${contents}] success!`); } }; @@ -6375,7 +6351,7 @@ async function doUpdateComment ( } if (contents) { - await doCreateCommentContent(owner, repo, commentId, contents); + await doCreateCommentContent(owner, repo, commentId, dealInput(contents)); } }; @@ -6397,8 +6373,20 @@ async function doUpdateIssue ( }) const issue_body = issue.data.body; const issue_title = issue.data.title; - const issue_labels = issue.data.labels; - const issue_assignees = issue.data.assignees; + + let issue_labels = []; + if (issue.data.labels.length > 0) { + issue.data.labels.forEach(it =>{ + issue_labels.push(it.name); + }); + } + + let issue_assignees = []; + if (issue.data.assignees.length > 0) { + issue.data.assignees.forEach(it =>{ + issue_assignees.push(it.login); + }); + } let params = { owner, @@ -6666,11 +6654,12 @@ main(); function dealInput (para) { let arr = []; if (para) { - if (typeof(para) === 'string') { - arr.push(para); - } else { - arr = para; - } + const paraArr = para.split(','); + paraArr.forEach(it => { + if(it.trim()){ + arr.push(it.trim()) + } + }) } return arr; }; diff --git a/src/advanced.js b/src/advanced.js index b470b08..f6f1f5e 100644 --- a/src/advanced.js +++ b/src/advanced.js @@ -126,15 +126,7 @@ async function doQueryIssues (owner, repo, labels, state) { issueMentioned ? params.mentioned = issueMentioned : null; if (labels) { - if (typeof(labels) === 'string') { - params.labels = labels; - } else { - let temp = ''; - labels.forEach((it,index) => { - index == labels.length - 1 ? temp += `${it}` : temp += `${it},`; - }); - params.labels = temp; - } + params.labels = labels; } const res = await octokit.issues.listForRepo(params); diff --git a/src/base.js b/src/base.js index 60fdb06..acfcca0 100644 --- a/src/base.js +++ b/src/base.js @@ -61,12 +61,12 @@ async function doCreateComment (owner, repo, issueNumber, body) { core.setOutput("comment-id", data.id); if (contents) { - await doCreateCommentContent(owner, repo, data.id, contents); + await doCreateCommentContent(owner, repo, data.id, dealInput(contents)); } }; -async function doCreateCommentContent(owner, repo, commentId) { - if (typeof(contents) === 'object') { +async function doCreateCommentContent(owner, repo, commentId, contents) { + if (contents.length) { contents.forEach(async item => { if (testContent(item)) { await octokit.reactions.createForIssueComment({ @@ -78,14 +78,6 @@ async function doCreateCommentContent(owner, repo, commentId) { core.info(`Actions: [create-reactions][${item}] success!`); } }) - } else if (typeof(contents) === 'string' && testContent(contents)) { - await octokit.reactions.createForIssueComment({ - owner, - repo, - comment_id: commentId, - content: contents - }); - core.info(`Actions: [create-reactions][${contents}] success!`); } }; @@ -104,12 +96,12 @@ async function doCreateIssue (owner, repo, title, body, labels, assignees) { core.setOutput("issue-number", data.number); if (contents) { - await doCreateIssueContent(owner, repo, data.number, contents); + await doCreateIssueContent(owner, repo, data.number, dealInput(contents)); } }; -async function doCreateIssueContent(owner, repo, issueNumber) { - if (typeof(contents) === 'object') { +async function doCreateIssueContent(owner, repo, issueNumber, contents) { + if (contents.length) { contents.forEach(async item => { if (testContent(item)) { await octokit.reactions.createForIssue({ @@ -121,14 +113,6 @@ async function doCreateIssueContent(owner, repo, issueNumber) { core.info(`Actions: [create-reactions][${item}] success!`); } }) - } else if (typeof(contents) === 'string' && testContent(contents)) { - await octokit.reactions.createForIssue({ - owner, - repo, - issue_number: issueNumber, - content: contents - }); - core.info(`Actions: [create-reactions][${contents}] success!`); } }; @@ -221,7 +205,7 @@ async function doUpdateComment ( } if (contents) { - await doCreateCommentContent(owner, repo, commentId, contents); + await doCreateCommentContent(owner, repo, commentId, dealInput(contents)); } }; @@ -243,8 +227,20 @@ async function doUpdateIssue ( }) const issue_body = issue.data.body; const issue_title = issue.data.title; - const issue_labels = issue.data.labels; - const issue_assignees = issue.data.assignees; + + let issue_labels = []; + if (issue.data.labels.length > 0) { + issue.data.labels.forEach(it =>{ + issue_labels.push(it.name); + }); + } + + let issue_assignees = []; + if (issue.data.assignees.length > 0) { + issue.data.assignees.forEach(it =>{ + issue_assignees.push(it.login); + }); + } let params = { owner, diff --git a/src/util.js b/src/util.js index e690696..e9824d4 100644 --- a/src/util.js +++ b/src/util.js @@ -1,11 +1,12 @@ function dealInput (para) { let arr = []; if (para) { - if (typeof(para) === 'string') { - arr.push(para); - } else { - arr = para; - } + const paraArr = para.split(','); + paraArr.forEach(it => { + if(it.trim()){ + arr.push(it.trim()) + } + }) } return arr; };