mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Lint large test repos in parallel (via worker threads) for shorter run times.
This commit is contained in:
parent
446fe901c3
commit
e447db33c9
5 changed files with 68 additions and 6 deletions
|
|
@ -5,7 +5,8 @@
|
|||
const { join } = require("node:path").posix;
|
||||
const jsoncParser = require("jsonc-parser");
|
||||
const jsYaml = require("js-yaml");
|
||||
const markdownlint = require("../lib/markdownlint");
|
||||
const { markdownlint, readConfig } = require("../lib/markdownlint").promises;
|
||||
const markdownlintParallel = require("./markdownlint-test-parallel");
|
||||
|
||||
/**
|
||||
* Lints a test repository.
|
||||
|
|
@ -13,9 +14,10 @@ const markdownlint = require("../lib/markdownlint");
|
|||
* @param {Object} t Test instance.
|
||||
* @param {string[]} globPatterns Array of files to in/exclude.
|
||||
* @param {string} configPath Path to config file.
|
||||
* @param {boolean} [parallel] True to lint in parallel.
|
||||
* @returns {Promise} Test result.
|
||||
*/
|
||||
async function lintTestRepo(t, globPatterns, configPath) {
|
||||
async function lintTestRepo(t, globPatterns, configPath, parallel) {
|
||||
t.plan(1);
|
||||
const { globby } = await import("globby");
|
||||
const jsoncParse = (json) => {
|
||||
|
|
@ -25,7 +27,7 @@ async function lintTestRepo(t, globPatterns, configPath) {
|
|||
const yamlParse = (yaml) => jsYaml.load(yaml);
|
||||
return Promise.all([
|
||||
globby(globPatterns),
|
||||
markdownlint.promises.readConfig(configPath, [ jsoncParse, yamlParse ])
|
||||
readConfig(configPath, [ jsoncParse, yamlParse ])
|
||||
]).then((globbyAndReadConfigResults) => {
|
||||
const [ files, rawConfig ] = globbyAndReadConfigResults;
|
||||
// eslint-disable-next-line no-console
|
||||
|
|
@ -37,7 +39,7 @@ async function lintTestRepo(t, globPatterns, configPath) {
|
|||
v
|
||||
])
|
||||
);
|
||||
return markdownlint.promises.markdownlint({
|
||||
return (parallel ? markdownlintParallel : markdownlint)({
|
||||
files,
|
||||
config
|
||||
}).then((results) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue