Skip to content

Commit

Permalink
Add "separator" input to enable using something other than "\n" for t…
Browse files Browse the repository at this point in the history
…he globs input (fixes #58).
  • Loading branch information
DavidAnson committed Nov 30, 2022
1 parent ee28a92 commit 9085e7e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/changed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
id: changed-files
with:
files: '**/*.md'
separator: "\n"
separator: ","
- uses: DavidAnson/markdownlint-cli2-action@v7
if: steps.changed-files.outputs.any_changed == 'true'
with:
globs: ${{ steps.changed-files.outputs.all_changed_files }}
separator: ","
13 changes: 13 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ jobs:
id: test
- run: exit 1
if: steps.test.outcome != 'failure'
separator:
name: Separator (README.md and test/errors.md, 3 errors)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
globs: '*.md,test/*'
separator: ','
continue-on-error: true
id: test
- run: exit 1
if: steps.test.outcome != 'failure'
command-config:
name: Command = config (test/errors.md, 2 errors)
runs-on: ubuntu-latest
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,20 @@ For more detail: [documentation for `markdownlint-cli2`][command-line].

### globs (optional)

Glob expression(s) of files to lint (newline-delimited)
Glob expression(s) of files to lint (newline-delimited by default)

The default `*.{md,markdown}` lints all Markdown files in the base directory
of a project.

For more detail: [glob syntax in `markdownlint-cli2`][glob-syntax].

### separator (optional)

String to use as a separator for the `globs` input (defaults to newline)

Allows the `globs` input to use something other than `\n` to separate glob
expressions.

## Outputs

[None]
Expand Down Expand Up @@ -67,6 +74,15 @@ To lint specific Markdown files in a project:
docs/*.md
```
To use a custom separator:
```yaml
- uses: DavidAnson/markdownlint-cli2-action@v7
with:
globs: 'README.md,CHANGELOG.md,docs/*.md'
separator: ','
```
To fix supported issues when linting:
```yaml
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: Glob expression(s) of files to lint (newline-delimited)
default: '*.{md,markdown}'
required: false
separator:
description: String to use as a separator for the "globs" input (defaults to newline)
default: "\n"
required: false
runs:
using: node16
main: dist/index.js
4 changes: 3 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34498,9 +34498,11 @@ const logError = (error) => {
}
core.error(error, annotation);
};

const separator = core.getInput("separator") || "\n";
const argv =
core.getInput("globs").
split("\n").
split(separator).
filter(String);

const parameters = {
Expand Down
4 changes: 3 additions & 1 deletion markdownlint-cli2-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ const logError = (error) => {
}
core.error(error, annotation);
};

const separator = core.getInput("separator") || "\n";
const argv =
core.getInput("globs").
split("\n").
split(separator).
filter(String);

const parameters = {
Expand Down

0 comments on commit 9085e7e

Please sign in to comment.