From 18f1c828a77533442400fddd5d6745324e1cdbd9 Mon Sep 17 00:00:00 2001 From: "Dmitry K." Date: Fri, 2 Aug 2024 15:52:44 -0700 Subject: [PATCH] replace all instances, not just first subsstring --- dist/index.js | 32 ++++++++++++++++---------------- src/index.js | 34 +++++++++++++++++----------------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/dist/index.js b/dist/index.js index 918061d..22748ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -51361,7 +51361,7 @@ class App { return; } - const {owner, repo} = github.context.repo; + const { owner, repo } = github.context.repo; const threadState = { state: threadData.state, @@ -51374,10 +51374,10 @@ class App { const thread = threadType === 'discussion' ? { - discussion_id: payload.discussion.node_id, - discussion_number: payload.discussion.number - } - : {owner, repo, issue_number: threadData.number}; + discussion_id: payload.discussion.node_id, + discussion_number: payload.discussion.number + } + : { owner, repo, issue_number: threadData.number }; if (actions.comment) { core.debug('Commenting'); @@ -51385,10 +51385,10 @@ class App { const commentAction = async () => { for (let commentBody of actions.comment) { commentBody = commentBody.replace( - /{issue-author}/, + /{issue-author}/g, threadData.user.login ).replace( - /{issue-id}/, + /{issue-id}/g, threadData.number ); @@ -51427,7 +51427,7 @@ class App { ({ repository: { discussion: { - labels: {nodes: currentLabels} + labels: { nodes: currentLabels } } } } = await this.client.graphql(getDiscussionLabelsQuery, { @@ -51452,7 +51452,7 @@ class App { const labels = []; for (const labelName of newLabels) { let { - repository: {label} + repository: { label } } = await this.client.graphql(getLabelQuery, { owner, repo, @@ -51461,12 +51461,12 @@ class App { if (!label) { ({ - createLabel: {label} + createLabel: { label } } = await this.client.graphql(createLabelQuery, { repositoryId: payload.repository.node_id, name: labelName, color: 'ffffff', - headers: {Accept: 'application/vnd.github.bane-preview+json'} + headers: { Accept: 'application/vnd.github.bane-preview+json' } })); } @@ -51527,7 +51527,7 @@ class App { reason: closeReason }); } else { - const params = {...thread, state: 'closed'}; + const params = { ...thread, state: 'closed' }; if (threadType === 'issue') { params.state_reason = closeReason; @@ -51551,7 +51551,7 @@ class App { discussionId: thread.discussion_id }); } else { - await this.client.rest.issues.update({...thread, state: 'open'}); + await this.client.rest.issues.update({ ...thread, state: 'open' }); } threadState.state = 'open'; @@ -51571,7 +51571,7 @@ class App { lockableId: thread.discussion_id }); } else { - const params = {...thread}; + const params = { ...thread }; if (lockReason) { params.lock_reason = lockReason; @@ -51641,7 +51641,7 @@ class App { }); } else { if (!threadState.hasOwnProperty('lockReason')) { - const {data: issueData} = await this.client.rest.issues.get(thread); + const { data: issueData } = await this.client.rest.issues.get(thread); threadState.lockReason = issueData.active_lock_reason; } @@ -51662,7 +51662,7 @@ class App { }); } else { if (threadState.lockReason) { - thread = {...thread, lock_reason: threadState.lockReason}; + thread = { ...thread, lock_reason: threadState.lockReason }; } await this.client.rest.issues.lock(thread); diff --git a/src/index.js b/src/index.js index 15e40b0..aa2e6cd 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,7 @@ import core from '@actions/core'; import github from '@actions/github'; -import {getConfig, getActionConfig, getClient} from './utils.js'; +import { getConfig, getActionConfig, getClient } from './utils.js'; import { addDiscussionCommentQuery, @@ -65,7 +65,7 @@ class App { return; } - const {owner, repo} = github.context.repo; + const { owner, repo } = github.context.repo; const threadState = { state: threadData.state, @@ -78,10 +78,10 @@ class App { const thread = threadType === 'discussion' ? { - discussion_id: payload.discussion.node_id, - discussion_number: payload.discussion.number - } - : {owner, repo, issue_number: threadData.number}; + discussion_id: payload.discussion.node_id, + discussion_number: payload.discussion.number + } + : { owner, repo, issue_number: threadData.number }; if (actions.comment) { core.debug('Commenting'); @@ -89,10 +89,10 @@ class App { const commentAction = async () => { for (let commentBody of actions.comment) { commentBody = commentBody.replace( - /{issue-author}/, + /{issue-author}/g, threadData.user.login ).replace( - /{issue-id}/, + /{issue-id}/g, threadData.number ); @@ -131,7 +131,7 @@ class App { ({ repository: { discussion: { - labels: {nodes: currentLabels} + labels: { nodes: currentLabels } } } } = await this.client.graphql(getDiscussionLabelsQuery, { @@ -156,7 +156,7 @@ class App { const labels = []; for (const labelName of newLabels) { let { - repository: {label} + repository: { label } } = await this.client.graphql(getLabelQuery, { owner, repo, @@ -165,12 +165,12 @@ class App { if (!label) { ({ - createLabel: {label} + createLabel: { label } } = await this.client.graphql(createLabelQuery, { repositoryId: payload.repository.node_id, name: labelName, color: 'ffffff', - headers: {Accept: 'application/vnd.github.bane-preview+json'} + headers: { Accept: 'application/vnd.github.bane-preview+json' } })); } @@ -231,7 +231,7 @@ class App { reason: closeReason }); } else { - const params = {...thread, state: 'closed'}; + const params = { ...thread, state: 'closed' }; if (threadType === 'issue') { params.state_reason = closeReason; @@ -255,7 +255,7 @@ class App { discussionId: thread.discussion_id }); } else { - await this.client.rest.issues.update({...thread, state: 'open'}); + await this.client.rest.issues.update({ ...thread, state: 'open' }); } threadState.state = 'open'; @@ -275,7 +275,7 @@ class App { lockableId: thread.discussion_id }); } else { - const params = {...thread}; + const params = { ...thread }; if (lockReason) { params.lock_reason = lockReason; @@ -345,7 +345,7 @@ class App { }); } else { if (!threadState.hasOwnProperty('lockReason')) { - const {data: issueData} = await this.client.rest.issues.get(thread); + const { data: issueData } = await this.client.rest.issues.get(thread); threadState.lockReason = issueData.active_lock_reason; } @@ -366,7 +366,7 @@ class App { }); } else { if (threadState.lockReason) { - thread = {...thread, lock_reason: threadState.lockReason}; + thread = { ...thread, lock_reason: threadState.lockReason }; } await this.client.rest.issues.lock(thread);