Skip to content

Commit

Permalink
Support args input (#14)
Browse files Browse the repository at this point in the history
* Support `args` input

* Update .github/workflows/main.yml

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>

* Update main.yml

---------

Co-authored-by: Nikolay Edigaryev <edigaryev@gmail.com>
  • Loading branch information
fkorotkov and edigaryev authored May 17, 2024
1 parent 82d3b9b commit fdc2695
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ jobs:
uses: ./
with:
version: 0.55.0
args: --enable-all-rules --in-process-sourcekit
5 changes: 2 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ inputs:
description: 'SwiftLint version to use or "latest" to query the latest available version'
required: false
default: 'latest'
strict:
description: 'Upgrades warnings to serious violations (errors)'
args:
description: 'Custom arguments to pass to SwiftLint'
required: false
default: 'false'

runs:
using: node20
Expand Down
8 changes: 7 additions & 1 deletion 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.

8 changes: 7 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import * as tr from '@actions/exec/lib/toolrunner'
import * as exec from '@actions/exec'
import path from 'path'
import * as process from 'node:process'
Expand Down Expand Up @@ -53,9 +54,14 @@ export async function run(): Promise<void> {
}

// Run the SwiftLint binary and capture its standard output
const swiftlintArgs = ['lint', '--reporter=json']
const additionalArgs = core.getInput('args')
if (additionalArgs) {
swiftlintArgs.push(...tr.argStringToArray(additionalArgs))
}
const output = await exec.getExecOutput(
path.join(portableSwiftlintDir, 'swiftlint'),
['lint', '--reporter=json'],
swiftlintArgs,
{
ignoreReturnCode: true
}
Expand Down

0 comments on commit fdc2695

Please sign in to comment.