Skip to content

Commit

Permalink
Add check for published packages before returning status skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
jill64 committed Dec 20, 2023
1 parent 74ed5e9 commit 70f10e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/action/src/ghosts/release/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ export const release: Ghost = async ({ payload: { owner, repo }, octokit }) => {
}
}

await Promise.allSettled(files.map(npmPublish))
const result = await Promise.allSettled(files.map(npmPublish))

if (!result.some((r) => r.status === 'fulfilled' && r.value)) {
return {
status: 'skipped',
detail: 'No package published'
}
}

Check warning on line 36 in packages/action/src/ghosts/release/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/action/src/ghosts/release/index.ts#L29-L36

Added lines #L29 - L36 were not covered by tests

const json = await getPackageJson()
const rootPackageJson = isValidPackageJson(json) ? json : null
Expand Down
6 changes: 4 additions & 2 deletions packages/action/src/ghosts/release/npmPublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const npmPublish = async (file: string) => {

if (!isValidJson(package_json)) {
core.info(`[${file}]: No version found.`)
return
return false

Check warning on line 21 in packages/action/src/ghosts/release/npmPublish.ts

View check run for this annotation

Codecov / codecov/patch

packages/action/src/ghosts/release/npmPublish.ts#L21

Added line #L21 was not covered by tests
}

const version = package_json.version.trim()
Expand All @@ -34,10 +34,12 @@ export const npmPublish = async (file: string) => {

if (version === publishedVersion.stdout.trim()) {
core.info(`[${file}]: No update found.`)
return
return false

Check warning on line 37 in packages/action/src/ghosts/release/npmPublish.ts

View check run for this annotation

Codecov / codecov/patch

packages/action/src/ghosts/release/npmPublish.ts#L37

Added line #L37 was not covered by tests
}

await exec.exec('npm publish', undefined, {
cwd
})

return true

Check warning on line 44 in packages/action/src/ghosts/release/npmPublish.ts

View check run for this annotation

Codecov / codecov/patch

packages/action/src/ghosts/release/npmPublish.ts#L43-L44

Added lines #L43 - L44 were not covered by tests
}

0 comments on commit 70f10e5

Please sign in to comment.