diff --git a/package.json b/package.json index 210c5e6a..b5c36045 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "eslint-plugin-jsdoc": "~37.4.0", "eslint-plugin-node": "~11.1.0", "eslint-plugin-unicorn": "~39.0.0", - "globby": "~11.0.4", + "globby": "~12.0.2", "js-yaml": "~4.1.0", "markdown-it-for-inline": "~0.1.1", "markdown-it-sub": "~1.0.0", diff --git a/scripts/index.js b/scripts/index.js index 0f31207b..de3f9141 100644 --- a/scripts/index.js +++ b/scripts/index.js @@ -2,20 +2,27 @@ "use strict"; -const fs = require("fs"); -const globby = require("globby"); +const fs = require("fs").promises; const [ command, ...args ] = process.argv.slice(2); -if (command === "copy") { - const [ src, dest ] = args; - fs.copyFileSync(src, dest); -} else if (command === "delete") { - for (const arg of args) { - for (const file of globby.sync(arg)) { - fs.unlinkSync(file); - } +// eslint-disable-next-line unicorn/prefer-top-level-await +(async() => { + if (command === "copy") { + const [ src, dest ] = args; + await fs.copyFile(src, dest); + } else if (command === "delete") { + // eslint-disable-next-line node/no-unsupported-features/es-syntax + const { globby } = await import("globby"); + await Promise.all( + args.flatMap( + (glob) => globby(glob) + .then( + (files) => files.map((file) => fs.unlink(file)) + ) + ) + ); + } else { + throw new Error(`Unsupported command: ${command}`); } -} else { - throw new Error(`Unsupported command: ${command}`); -} +})(); diff --git a/test/markdownlint-test-extra-parse.js b/test/markdownlint-test-extra-parse.js index 9f88e10f..7c96500d 100644 --- a/test/markdownlint-test-extra-parse.js +++ b/test/markdownlint-test-extra-parse.js @@ -2,18 +2,15 @@ "use strict"; -const globby = require("globby"); const test = require("ava").default; const markdownlint = require("../lib/markdownlint"); // Parses all Markdown files in all package dependencies -test.cb("parseAllFiles", (t) => { +test("parseAllFiles", async(t) => { t.plan(1); - const options = { - "files": globby.sync("**/*.{md,markdown}") - }; - markdownlint(options, (err) => { - t.falsy(err); - t.end(); - }); + // eslint-disable-next-line node/no-unsupported-features/es-syntax + const { globby } = await import("globby"); + const files = await globby("**/*.{md,markdown}"); + await markdownlint.promises.markdownlint({ files }); + t.pass(); }); diff --git a/test/markdownlint-test-repos.js b/test/markdownlint-test-repos.js index 1363792b..aefd9889 100644 --- a/test/markdownlint-test-repos.js +++ b/test/markdownlint-test-repos.js @@ -6,7 +6,6 @@ const { existsSync } = require("fs"); // eslint-disable-next-line unicorn/import-style const { join } = require("path"); const { promisify } = require("util"); -const globby = require("globby"); const jsYaml = require("js-yaml"); const test = require("ava").default; const markdownlint = require("../lib/markdownlint"); @@ -25,6 +24,8 @@ const readConfigPromise = promisify(markdownlint.readConfig); async function lintTestRepo(t, globPatterns, configPath, ignoreRes) { t.plan(1); // eslint-disable-next-line node/no-unsupported-features/es-syntax + const { globby } = await import("globby"); + // eslint-disable-next-line node/no-unsupported-features/es-syntax const { "default": stripJsonComments } = await import("strip-json-comments"); const jsoncParse = (json) => JSON.parse(stripJsonComments(json)); const yamlParse = (yaml) => jsYaml.load(yaml);