Skip to content

Commit

Permalink
replace all instances, not just first subsstring
Browse files Browse the repository at this point in the history
  • Loading branch information
okdas committed Aug 2, 2024
1 parent 52206df commit 18f1c82
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 33 deletions.
32 changes: 16 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51361,7 +51361,7 @@ class App {
return;
}

const {owner, repo} = github.context.repo;
const { owner, repo } = github.context.repo;

const threadState = {
state: threadData.state,
Expand All @@ -51374,21 +51374,21 @@ 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');

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
);

Expand Down Expand Up @@ -51427,7 +51427,7 @@ class App {
({
repository: {
discussion: {
labels: {nodes: currentLabels}
labels: { nodes: currentLabels }
}
}
} = await this.client.graphql(getDiscussionLabelsQuery, {
Expand All @@ -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,
Expand All @@ -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' }
}));
}

Expand Down Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -51571,7 +51571,7 @@ class App {
lockableId: thread.discussion_id
});
} else {
const params = {...thread};
const params = { ...thread };

if (lockReason) {
params.lock_reason = lockReason;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down
34 changes: 17 additions & 17 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -65,7 +65,7 @@ class App {
return;
}

const {owner, repo} = github.context.repo;
const { owner, repo } = github.context.repo;

const threadState = {
state: threadData.state,
Expand All @@ -78,21 +78,21 @@ 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');

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
);

Expand Down Expand Up @@ -131,7 +131,7 @@ class App {
({
repository: {
discussion: {
labels: {nodes: currentLabels}
labels: { nodes: currentLabels }
}
}
} = await this.client.graphql(getDiscussionLabelsQuery, {
Expand All @@ -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,
Expand All @@ -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' }
}));
}

Expand Down Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -275,7 +275,7 @@ class App {
lockableId: thread.discussion_id
});
} else {
const params = {...thread};
const params = { ...thread };

if (lockReason) {
params.lock_reason = lockReason;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand Down

0 comments on commit 18f1c82

Please sign in to comment.