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
27 changes: 25 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
version: ^0.17
token: ${{ secrets.GITHUB_TOKEN }}
args: --check ./test
args: --check ./test/sample.lua
smoketest_latest_version_provided:
runs-on: ubuntu-latest
steps:
Expand All @@ -44,4 +44,27 @@ jobs:
with:
version: latest
token: ${{ secrets.GITHUB_TOKEN }}
args: --check ./test
args: --check ./test/sample.lua
# only install / cache the StyLua install, don't run it
smoketest_args_false:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Copy Test File
run: |
cp ./test/needs_spaces.lua{,.copy}

- uses: ./
with:
version: latest
token: ${{ secrets.GITHUB_TOKEN }}
args: false

- name: Confirm test file was not changed
run: |
cmp ./test/needs_spaces.lua{,.copy}

- name: Can run stylua independently
run: |
stylua --version
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ Installs the StyLua binary (from GitHub releases), and caches it. Any StyLua com
args: --check .
```

If you would just like to install `stylua`, but not run it (e.g., since it is used as part of a wider CI script), then
you can set `args: false`:

```yaml
- uses: actions/checkout@v4
- uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
# This disables running `stylua`
args: false
# Run stylua independently
- run: |
stylua --version
```

### Parameters

#### `token` (Required)
Expand All @@ -26,7 +42,7 @@ GitHub token. Required since the binary is downloaded from GitHub releases (to s

#### `args` (Required)

The arguments to pass to the StyLua binary
The arguments to pass to the StyLua binary. If you don't want to run the binary, set `args: false`.

#### `version` (Required)

Expand Down
4 changes: 3 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.

5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ async function run(): Promise<void> {
const args = core.getInput('args')
core.debug(`Running stylua with arguments: ${args}`)

await exec(`stylua ${args}`)
if (args !== 'false') {
await exec(`stylua ${args}`)
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
} catch (error: any) {
core.setFailed(error.message)
Expand Down
1 change: 1 addition & 0 deletions test/needs_spaces.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local x=1