mirror of
https://github.com/haskell-actions/run-ormolu.git
synced 2024-11-29 12:22:17 +03:00
Add mode
input
This commit is contained in:
parent
51664d3a0b
commit
46243e8f9f
20
README.md
20
README.md
@ -17,6 +17,8 @@ and its formatted version.
|
||||
account their `default-extensions` and `default-language` settings
|
||||
(default: true).
|
||||
* `follow-symbolic-links` Whether to follow symbolic links (default: true).
|
||||
* `mode` Specifies whether to simply `"check"` files for formatting, or
|
||||
modify the files `"inplace"`.
|
||||
* `extra-args` Extra arguments to pass to Ormolu.
|
||||
* `version` The version number of Ormolu to use. Defaults to `"latest"`.
|
||||
|
||||
@ -61,3 +63,21 @@ passes.
|
||||
[ormolu]: https://github.com/tweag/ormolu
|
||||
[multiple-patterns-example]: https://github.com/haskell-actions/run-ormolu/blob/master/action.yml#L9-L11
|
||||
[git-core-autocrlf]: https://www.git-scm.com/docs/git-config#Documentation/git-config.txt-coreautocrlf
|
||||
|
||||
## Example which commits the formatted files:
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
ormolu:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: haskell-actions/run-ormolu@v14
|
||||
with:
|
||||
mode: inplace
|
||||
- name: apply formatting changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
if: ${{ always() }}
|
||||
with:
|
||||
commit_message: automated ormolu commit
|
||||
```
|
||||
|
@ -20,6 +20,11 @@ inputs:
|
||||
description: >
|
||||
Whether to follow symbolic links.
|
||||
default: true
|
||||
mode:
|
||||
required: false
|
||||
description: >
|
||||
Mode of operation: 'stdout', 'inplace', or 'check' (the default).
|
||||
default: 'check'
|
||||
extra-args:
|
||||
required: false
|
||||
description: >
|
||||
|
3
dist/index.js
vendored
3
dist/index.js
vendored
@ -26,6 +26,7 @@ const ormolu_macos_url = 'https://github.com/tweag/ormolu/releases/download/' +
|
||||
const input_pattern = core.getInput('pattern');
|
||||
const input_respect_cabal_files = core.getInput('respect-cabal-files').toUpperCase() !== 'FALSE';
|
||||
const input_follow_symbolic_links = core.getInput('follow-symbolic-links').toUpperCase() !== 'FALSE';
|
||||
const input_mode = core.getInput('mode').toLowerCase();
|
||||
const input_extra_args = core.getInput('extra-args');
|
||||
|
||||
async function run() {
|
||||
@ -97,7 +98,7 @@ async function run() {
|
||||
if (files.length > 0) {
|
||||
await exec.exec(
|
||||
ormolu_cached_path,
|
||||
['--color', 'always', '--check-idempotence', '--mode', 'check']
|
||||
['--color', 'always', '--check-idempotence', '--mode', input_mode]
|
||||
.concat(respect_cabal_files)
|
||||
.concat(extra_args)
|
||||
.concat(files)
|
||||
|
3
index.js
3
index.js
@ -15,6 +15,7 @@ const ormolu_macos_url = 'https://github.com/tweag/ormolu/releases/download/' +
|
||||
const input_pattern = core.getInput('pattern');
|
||||
const input_respect_cabal_files = core.getInput('respect-cabal-files').toUpperCase() !== 'FALSE';
|
||||
const input_follow_symbolic_links = core.getInput('follow-symbolic-links').toUpperCase() !== 'FALSE';
|
||||
const input_mode = core.getInput('mode').toLowerCase();
|
||||
const input_extra_args = core.getInput('extra-args');
|
||||
|
||||
async function run() {
|
||||
@ -86,7 +87,7 @@ async function run() {
|
||||
if (files.length > 0) {
|
||||
await exec.exec(
|
||||
ormolu_cached_path,
|
||||
['--color', 'always', '--check-idempotence', '--mode', 'check']
|
||||
['--color', 'always', '--check-idempotence', '--mode', input_mode]
|
||||
.concat(respect_cabal_files)
|
||||
.concat(extra_args)
|
||||
.concat(files)
|
||||
|
Loading…
Reference in New Issue
Block a user