From 9085e7e0dcce6a49234ccba26a103c4e7feca030 Mon Sep 17 00:00:00 2001 From: David Anson Date: Wed, 30 Nov 2022 03:29:42 +0000 Subject: [PATCH] Add "separator" input to enable using something other than "\n" for the globs input (fixes #58). --- .github/workflows/changed.yml | 3 ++- .github/workflows/test.yml | 13 +++++++++++++ README.md | 18 +++++++++++++++++- action.yml | 4 ++++ dist/index.js | 4 +++- markdownlint-cli2-action.js | 4 +++- 6 files changed, 42 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changed.yml b/.github/workflows/changed.yml index 07cc52c..03e3a32 100644 --- a/.github/workflows/changed.yml +++ b/.github/workflows/changed.yml @@ -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: "," diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 752317c..c90d7fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/README.md b/README.md index c414bea..ab98883 100644 --- a/README.md +++ b/README.md @@ -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] @@ -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 diff --git a/action.yml b/action.yml index 496ef70..760349f 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/dist/index.js b/dist/index.js index 52d9bd5..1c6fc90 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 = { diff --git a/markdownlint-cli2-action.js b/markdownlint-cli2-action.js index 316b246..484b090 100644 --- a/markdownlint-cli2-action.js +++ b/markdownlint-cli2-action.js @@ -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 = {