Skip to content

Commit 1204822

Browse files
committed
feat(run): args: false will install+cache but not run
1 parent b666182 commit 1204822

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

.github/workflows/test.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
version: ^0.17
3737
token: ${{ secrets.GITHUB_TOKEN }}
38-
args: --check ./test
38+
args: --check ./test/sample.lua
3939
smoketest_latest_version_provided:
4040
runs-on: ubuntu-latest
4141
steps:
@@ -44,4 +44,23 @@ jobs:
4444
with:
4545
version: latest
4646
token: ${{ secrets.GITHUB_TOKEN }}
47-
args: --check ./test
47+
args: --check ./test/sample.lua
48+
# only install / cache the StyLua install, don't run it
49+
smoketest_args_false:
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
54+
- name: Copy Test File
55+
run: |
56+
cp ./test/needs_spaces.lua{,.copy}
57+
58+
- uses: ./
59+
with:
60+
version: latest
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
args: false
63+
64+
- name: Confirm test file was not changed
65+
run: |
66+
cmp ./test/needs_spaces.lua{,.copy}

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ Installs the StyLua binary (from GitHub releases), and caches it. Any StyLua com
1818
args: --check .
1919
```
2020
21+
### Advanced Usage - Skip Running StyLua
22+
This action can be summarized as 2 main steps
23+
24+
1. Get An Installation Of [StyLua](https://github.com/JohnnyMorganz/StyLua)
25+
1a. From the cache
26+
1b. If no cache, install + cache it
27+
2. Run `stylua` with the user-provided `args`
28+
29+
If you would like to keep step 1 but skip step 2 because you want more manual
30+
control, use `args: false`.
31+
32+
```yaml
33+
- uses: actions/checkout@v4
34+
- uses: JohnnyMorganz/stylua-action@v4
35+
with:
36+
token: ${{ secrets.GITHUB_TOKEN }}
37+
version: latest # NOTE: we recommend pinning to a specific version in case of formatting changes
38+
# This disables running `stylua`
39+
args: false
40+
```
41+
2142
### Parameters
2243
2344
#### `token` (Required)

dist/index.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ async function run(): Promise<void> {
5656
const args = core.getInput('args')
5757
core.debug(`Running stylua with arguments: ${args}`)
5858

59-
await exec(`stylua ${args}`)
59+
if (args !== 'false') {
60+
await exec(`stylua ${args}`)
61+
}
62+
6063
// eslint-disable-next-line @typescript-eslint/no-explicit-any
6164
} catch (error: any) {
6265
core.setFailed(error.message)

test/needs_spaces.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local x=1

0 commit comments

Comments
 (0)