Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main.ts #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as core from '@actions/core'
import {context, GitHub} from '@actions/github'

type Format = 'space-delimited' | 'csv' | 'json'
type FileStatus = 'added' | 'modified' | 'removed' | 'renamed'
type FileStatus = 'added' | 'modified' | 'removed' | 'renamed'

async function run(): Promise<void> {
try {
Expand Down Expand Up @@ -89,7 +89,8 @@ async function run(): Promise<void> {
modified = [] as string[],
removed = [] as string[],
renamed = [] as string[],
addedModified = [] as string[]
addedModified = [] as string[],
allMinusDeleted = [] as string[],
for (const file of files) {
const filename = file.filename
// If we're using the 'space-delimited' format and any of the filenames have a space in them,
Expand All @@ -105,13 +106,16 @@ async function run(): Promise<void> {
case 'added':
added.push(filename)
addedModified.push(filename)
allMinusDeleted.push(filename)
break
case 'modified':
modified.push(filename)
addedModified.push(filename)
allMinusDeleted.push(filename)
break
case 'removed':
removed.push(filename)
allMinusDeleted.push(filename)
break
case 'renamed':
renamed.push(filename)
Expand All @@ -130,6 +134,7 @@ async function run(): Promise<void> {
removedFormatted: string,
renamedFormatted: string,
addedModifiedFormatted: string
allMinusDeletedFormatted: string
switch (format) {
case 'space-delimited':
// If any of the filenames have a space in them, then fail the step.
Expand All @@ -145,6 +150,7 @@ async function run(): Promise<void> {
removedFormatted = removed.join(' ')
renamedFormatted = renamed.join(' ')
addedModifiedFormatted = addedModified.join(' ')
allMinusDeletedFormatted = allMinusDeleted.join(' ')
break
case 'csv':
allFormatted = all.join(',')
Expand All @@ -153,6 +159,7 @@ async function run(): Promise<void> {
removedFormatted = removed.join(',')
renamedFormatted = renamed.join(',')
addedModifiedFormatted = addedModified.join(',')
allMinusDeletedFormatted = allMinusDeleted.join(',')
break
case 'json':
allFormatted = JSON.stringify(all)
Expand All @@ -161,6 +168,7 @@ async function run(): Promise<void> {
removedFormatted = JSON.stringify(removed)
renamedFormatted = JSON.stringify(renamed)
addedModifiedFormatted = JSON.stringify(addedModified)
allMinusDeletedFormatted = JSON.stringify(allMinusDeleted)
break
}

Expand All @@ -171,6 +179,7 @@ async function run(): Promise<void> {
core.info(`Removed: ${removedFormatted}`)
core.info(`Renamed: ${renamedFormatted}`)
core.info(`Added or modified: ${addedModifiedFormatted}`)
core.info(`All minus deleted: ${allMinusDeletedFormatted}`)

// Set step output context.
core.setOutput('all', allFormatted)
Expand All @@ -179,6 +188,7 @@ async function run(): Promise<void> {
core.setOutput('removed', removedFormatted)
core.setOutput('renamed', renamedFormatted)
core.setOutput('added_modified', addedModifiedFormatted)
core.setOutput('all_minus_deleted', allMinusDeletedFormatted)

// For backwards-compatibility
core.setOutput('deleted', removedFormatted)
Expand Down