Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ jobs:
matrix:
verbosity:
- xcpretty
- xcbeautify
- quiet
- verbose
steps:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ inputs:
required: false
default: 'false'
verbosity:
description: One of `xcpretty`, `quiet` or `verbose`.
description: One of `xcpretty`, `xcbeautify`, `quiet` or `verbose`.
default: xcpretty
required: false
upload-logs:
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function main() {
const warningsAsErrors = core.getBooleanInput('warnings-as-errors')
const destination = await getDestination(selected, platform, platformVersion)
const identity = getIdentity(core.getInput('code-sign-identity'), platform)
const xcpretty = verbosity() == 'xcpretty'
const currentVerbosity = verbosity()
const workspace = core.getInput('workspace')

core.info(`» Selected Xcode ${selected}`)
Expand Down Expand Up @@ -211,7 +211,7 @@ async function main() {
if (arch) args = args.concat([`-arch=${arch}`])
if (workspace) args = args.concat(['-workspace', workspace])
if (identity) args = args.concat(identity)
if (verbosity() == 'quiet') args.push('-quiet')
if (currentVerbosity == 'quiet') args.push('-quiet')
if (configuration) args = args.concat(['-configuration', configuration])
if (apiKey) args = args.concat(apiKey)

Expand All @@ -238,7 +238,7 @@ async function main() {

if (action) args.push(action)

await xcodebuildX(args, xcpretty)
await xcodebuildX(args, currentVerbosity)
})
}

Expand Down
5 changes: 4 additions & 1 deletion src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,13 @@ async function exec(
}
}

export function verbosity(): 'xcpretty' | 'quiet' | 'verbose' {
export type Verbosity = 'xcpretty' | 'xcbeautify' | 'quiet' | 'verbose'

export function verbosity(): Verbosity {
const value = core.getInput('verbosity')
switch (value) {
case 'xcpretty':
case 'xcbeautify':
case 'quiet':
case 'verbose':
return value
Expand Down
17 changes: 10 additions & 7 deletions src/xcodebuild.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import { spawn } from 'child_process'
import * as core from '@actions/core'
import { Verbosity } from './lib'

type SpawnResult = number | NodeJS.Signals | null

export default async function xcodebuild(
args: string[],
xcpretty: boolean
verbosity: Verbosity
): Promise<void> {
const needsPipe = verbosity === 'xcpretty' || verbosity === 'xcbeautify'

const xcodebuild = spawn('xcodebuild', args, {
stdio: ['inherit', xcpretty ? 'pipe' : 'inherit', 'inherit'],
stdio: ['inherit', needsPipe ? 'pipe' : 'inherit', 'inherit'],
})

let promise = new Promise<SpawnResult>((fulfill, reject) => {
xcodebuild.on('error', reject)
xcodebuild.on('exit', (status, signal) => fulfill(status ?? signal))
})

if (xcpretty) {
const xcpretty = spawn('xcpretty', {
if (needsPipe) {
const processResponse = spawn(verbosity, {
stdio: ['pipe', process.stdout, 'inherit'],
})

xcodebuild.stdout?.pipe(xcpretty.stdin)
xcodebuild.stdout?.pipe(processResponse.stdin)

promise = promise.then(
(status0) =>
new Promise<SpawnResult>((fulfill, reject) => {
xcpretty.on('error', reject)
xcpretty.on('exit', (status, signal) =>
processResponse.on('error', reject)
processResponse.on('exit', (status, signal) =>
fulfill(status0 ?? status ?? signal)
)
})
Expand Down