mirror of
https://github.com/DavidAnson/markdownlint-cli2-action.git
synced 2024-11-24 07:06:23 +01:00
This commit is contained in:
parent
4309653070
commit
0820d56e6c
7 changed files with 113 additions and 12 deletions
35
.github/workflows/test.yml
vendored
35
.github/workflows/test.yml
vendored
|
@ -38,3 +38,38 @@ jobs:
|
|||
globs: |
|
||||
*.md
|
||||
test/*
|
||||
command-config:
|
||||
name: Command = config (test/errors.md, errors)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
command: config
|
||||
globs: |
|
||||
config/.markdownlint.jsonc
|
||||
test/*
|
||||
command-config-missing:
|
||||
name: Command = config (missing configuration file)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
command: config
|
||||
command-fix:
|
||||
name: Command = fix (test/errors.md, no errors)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
command: fix
|
||||
command-unsupported:
|
||||
name: Command = unsupported (fails)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: ./
|
||||
with:
|
||||
command: unsupported
|
||||
|
|
17
README.md
17
README.md
|
@ -13,6 +13,20 @@ information.
|
|||
|
||||
## Inputs
|
||||
|
||||
### command (optional)
|
||||
|
||||
Command to run (unset, `fix`, or `config`)
|
||||
|
||||
If unspecified or `""`, the `markdownlint-cli2` command is run.
|
||||
|
||||
If set to `fix`, the `markdownlint-cli2-fix` command is run and supported
|
||||
issues will be fixed automatically.
|
||||
|
||||
If set to `config`, the `markdownlint-cli2-config` command is run and the
|
||||
first element of `globs` should specify a supported configuration file.
|
||||
|
||||
For more detail: [command line documentation for `markdownlint-cli2`][command-line].
|
||||
|
||||
### globs (optional)
|
||||
|
||||
Glob expression(s) of files to lint (newline-delimited)
|
||||
|
@ -20,7 +34,7 @@ Glob expression(s) of files to lint (newline-delimited)
|
|||
The default `*.{md,markdown}` lints all Markdown files in the base directory
|
||||
of a project.
|
||||
|
||||
For more detail, read about [glob syntax in `markdownlint-cli2`][glob-syntax].
|
||||
For more detail: [glob syntax in `markdownlint-cli2`][glob-syntax].
|
||||
|
||||
## Outputs
|
||||
|
||||
|
@ -63,6 +77,7 @@ To prevent linting issues from failing the workflow run:
|
|||
See [`example.yml`][example-yml] for a simple GitHub workflow that uses
|
||||
`markdownlint-cli2-action`.
|
||||
|
||||
[command-line]: https://github.com/DavidAnson/markdownlint-cli2#command-line
|
||||
[commonmark]: https://commonmark.org/
|
||||
[example-yml]: .github/workflows/example.yml
|
||||
[glob-syntax]: https://github.com/DavidAnson/markdownlint-cli2#use
|
||||
|
|
|
@ -5,6 +5,10 @@ branding:
|
|||
icon: 'check-square'
|
||||
color: 'orange'
|
||||
inputs:
|
||||
command:
|
||||
description: 'Command to run (unset, "fix", or "config")'
|
||||
default: ''
|
||||
required: false
|
||||
globs:
|
||||
description: 'Glob expression(s) of files to lint (newline-delimited)'
|
||||
default: '*.{md,markdown}'
|
||||
|
|
3
config/.markdownlint.jsonc
Normal file
3
config/.markdownlint.jsonc
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"single-trailing-newline": false
|
||||
}
|
32
dist/index.js
vendored
32
dist/index.js
vendored
|
@ -32158,14 +32158,36 @@ const argv =
|
|||
split("\n").
|
||||
filter(String);
|
||||
|
||||
markdownlintCli2({
|
||||
const parameters = {
|
||||
argv,
|
||||
logMessage,
|
||||
logError
|
||||
}).then(
|
||||
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
||||
(error) => core.setFailed(`Failed due to error: ${error}`)
|
||||
);
|
||||
};
|
||||
let invoke = true;
|
||||
const command = core.getInput("command");
|
||||
switch (command) {
|
||||
case "":
|
||||
// Default behavior
|
||||
break;
|
||||
case "config":
|
||||
parameters.name = "markdownlint-cli2-config";
|
||||
break;
|
||||
case "fix":
|
||||
parameters.name = "markdownlint-cli2-fix";
|
||||
parameters.fixDefault = true;
|
||||
break;
|
||||
default:
|
||||
core.setFailed(`Unsupported command: ${command}`);
|
||||
invoke = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (invoke) {
|
||||
markdownlintCli2(parameters).then(
|
||||
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
||||
(error) => core.setFailed(`Failed due to error: ${error}`)
|
||||
);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
|
|
@ -37,11 +37,33 @@ const argv =
|
|||
split("\n").
|
||||
filter(String);
|
||||
|
||||
markdownlintCli2({
|
||||
const parameters = {
|
||||
argv,
|
||||
logMessage,
|
||||
logError
|
||||
}).then(
|
||||
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
||||
(error) => core.setFailed(`Failed due to error: ${error}`)
|
||||
);
|
||||
};
|
||||
let invoke = true;
|
||||
const command = core.getInput("command");
|
||||
switch (command) {
|
||||
case "":
|
||||
// Default behavior
|
||||
break;
|
||||
case "config":
|
||||
parameters.name = "markdownlint-cli2-config";
|
||||
break;
|
||||
case "fix":
|
||||
parameters.name = "markdownlint-cli2-fix";
|
||||
parameters.fixDefault = true;
|
||||
break;
|
||||
default:
|
||||
core.setFailed(`Unsupported command: ${command}`);
|
||||
invoke = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (invoke) {
|
||||
markdownlintCli2(parameters).then(
|
||||
(code) => code && core.setFailed(`Failed with exit code: ${code}`),
|
||||
(error) => core.setFailed(`Failed due to error: ${error}`)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
"build": "ncc build markdownlint-cli2-action.js",
|
||||
"docker-npm-install": "docker run --rm --tty --name npm-install --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm install",
|
||||
"docker-npm-run-upgrade": "docker run --rm --tty --name npm-run-upgrade --volume $PWD:/home/workdir --workdir /home/workdir --user node node:16 npm run upgrade",
|
||||
"lint": "eslint *.js",
|
||||
"lint": "eslint *.js && markdownlint-cli2 *.md",
|
||||
"test": "npm run lint && npm run build && git diff --exit-code",
|
||||
"upgrade": "npx --yes npm-check-updates --upgrade"
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue