Skip to content

Commit

Permalink
Wrong param usage
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoni committed Feb 22, 2024
1 parent e4a1dd1 commit 18510dd
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('parseProjectName', () => {

test('returns the given branch without the suffix when a suffixRemove is passed', async () => {
const baseBranch = 'feature/work'
const sufixRemove = '/work'
const projectName = parseProjectName({baseBranch, sufixRemove})
const suffixRemove = '/work'
const projectName = parseProjectName({baseBranch, suffixRemove})

expect(projectName).toEqual('feature')
})
Expand Down
13 changes: 6 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface ParseProjectName {
baseBranch: string
prefixRemove?: string
sufixRemove?: string
suffixRemove?: string
replaceWithSpaces?: string
}

Expand Down
8 changes: 3 additions & 5 deletions src/project-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function getProjectId(params: ParsedProjectUrl): Promise<string | v
// First, use the GraphQL API to request the template project's node ID.
const idResp = await octokit.graphql<ProjectNodeIDResponse>(
`query getProject($ownerName: String!, $projectNumber: Int!) {
${ownerType}(login: $ownerNamee) {
${ownerType}(login: $ownerName) {
projectV2(number: $projectNumber) {
id
}
Expand All @@ -46,8 +46,6 @@ export async function projectLink(): Promise<void> {
const ownerName = github.context.payload.repository?.owner.login ?? ''
const ownerId = github.context.payload.repository?.owner.id ?? ''

core.debug(`Repository Payload: \n ${JSON.stringify(github.context.payload.repository, null, 2)}`)

if (!ownerName || !ownerId) {
throw new Error('Could not determine repository owner')
}
Expand All @@ -71,8 +69,8 @@ export async function projectLink(): Promise<void> {

const projectName = parseProjectName({
baseBranch,
prefixRemove: core.getInput('prefix-remove'),
sufixRemove: core.getInput('sufix-remove'),
prefixRemove: core.getInput('name-prefix-remove'),
suffixRemove: core.getInput('name-suffix-remove'),
replaceWithSpaces: core.getInput('replace-with-spaces'),
})

Expand Down
6 changes: 3 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {ParseProjectName, ParsedProjectUrl} from './interfaces'
* @returns {string} The project name.
*/
export const parseProjectName = (params: ParseProjectName): string => {
const {baseBranch, prefixRemove, sufixRemove, replaceWithSpaces} = params
const {baseBranch, prefixRemove, suffixRemove, replaceWithSpaces} = params

let projectName = baseBranch
if (prefixRemove) {
projectName = projectName.replace(new RegExp(`^${prefixRemove}`, 'i'), '')
}

if (sufixRemove) {
projectName = projectName.replace(new RegExp(`${sufixRemove}$`, 'i'), '')
if (suffixRemove) {
projectName = projectName.replace(new RegExp(`${suffixRemove}$`, 'i'), '')
}

if (replaceWithSpaces) {
Expand Down

0 comments on commit 18510dd

Please sign in to comment.