Skip to content

Commit 6c2d8f5

Browse files
NachoSotomxcl
authored andcommitted
Add support for xcbeautify
Fixes #114
1 parent e1b8e29 commit 6c2d8f5

File tree

7 files changed

+21
-14
lines changed

7 files changed

+21
-14
lines changed

.github/workflows/checks.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ jobs:
201201
matrix:
202202
verbosity:
203203
- xcpretty
204+
- xcbeautify
204205
- quiet
205206
- verbose
206207
steps:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ inputs:
119119
required: false
120120
default: 'false'
121121
verbosity:
122-
description: One of `xcpretty`, `quiet` or `verbose`.
122+
description: One of `xcpretty`, `xcbeautify`, `quiet` or `verbose`.
123123
default: xcpretty
124124
required: false
125125
upload-logs:

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ async function main() {
4545
const warningsAsErrors = core.getBooleanInput('warnings-as-errors')
4646
const destination = await getDestination(selected, platform, platformVersion)
4747
const identity = getIdentity(core.getInput('code-sign-identity'), platform)
48-
const xcpretty = verbosity() == 'xcpretty'
48+
const currentVerbosity = verbosity()
4949
const workspace = core.getInput('workspace')
5050

5151
core.info(`» Selected Xcode ${selected}`)
@@ -211,7 +211,7 @@ async function main() {
211211
if (arch) args = args.concat([`-arch=${arch}`])
212212
if (workspace) args = args.concat(['-workspace', workspace])
213213
if (identity) args = args.concat(identity)
214-
if (verbosity() == 'quiet') args.push('-quiet')
214+
if (currentVerbosity == 'quiet') args.push('-quiet')
215215
if (configuration) args = args.concat(['-configuration', configuration])
216216
if (apiKey) args = args.concat(apiKey)
217217

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

239239
if (action) args.push(action)
240240

241-
await xcodebuildX(args, xcpretty)
241+
await xcodebuildX(args, currentVerbosity)
242242
})
243243
}
244244

src/lib.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,13 @@ async function exec(
268268
}
269269
}
270270

271-
export function verbosity(): 'xcpretty' | 'quiet' | 'verbose' {
271+
export type Verbosity = 'xcpretty' | 'xcbeautify' | 'quiet' | 'verbose'
272+
273+
export function verbosity(): Verbosity {
272274
const value = core.getInput('verbosity')
273275
switch (value) {
274276
case 'xcpretty':
277+
case 'xcbeautify':
275278
case 'quiet':
276279
case 'verbose':
277280
return value

src/xcodebuild.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
import { spawn } from 'child_process'
22
import * as core from '@actions/core'
3+
import { Verbosity } from './lib'
34

45
type SpawnResult = number | NodeJS.Signals | null
56

67
export default async function xcodebuild(
78
args: string[],
8-
xcpretty: boolean
9+
verbosity: Verbosity
910
): Promise<void> {
11+
const needsPipe = verbosity === 'xcpretty' || verbosity === 'xcbeautify'
12+
1013
const xcodebuild = spawn('xcodebuild', args, {
11-
stdio: ['inherit', xcpretty ? 'pipe' : 'inherit', 'inherit'],
14+
stdio: ['inherit', needsPipe ? 'pipe' : 'inherit', 'inherit'],
1215
})
1316

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

19-
if (xcpretty) {
20-
const xcpretty = spawn('xcpretty', {
22+
if (needsPipe) {
23+
const processResponse = spawn(verbosity, {
2124
stdio: ['pipe', process.stdout, 'inherit'],
2225
})
2326

24-
xcodebuild.stdout?.pipe(xcpretty.stdin)
27+
xcodebuild.stdout?.pipe(processResponse.stdin)
2528

2629
promise = promise.then(
2730
(status0) =>
2831
new Promise<SpawnResult>((fulfill, reject) => {
29-
xcpretty.on('error', reject)
30-
xcpretty.on('exit', (status, signal) =>
32+
processResponse.on('error', reject)
33+
processResponse.on('exit', (status, signal) =>
3134
fulfill(status0 ?? status ?? signal)
3235
)
3336
})

0 commit comments

Comments
 (0)