From 2515ee22f0f3610658ffc40cc0b3c9f4d1abe95f Mon Sep 17 00:00:00 2001 From: David Anson Date: Thu, 1 Feb 2024 20:55:05 -0800 Subject: [PATCH] Refactor to defer (and avoid) a tiny amount of work in readConfig and importOrRequireConfig. --- markdownlint-cli2.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/markdownlint-cli2.js b/markdownlint-cli2.js index 8d9acea5..ae38dcfe 100755 --- a/markdownlint-cli2.js +++ b/markdownlint-cli2.js @@ -61,9 +61,9 @@ const resolveModulePaths = (dir, modulePaths) => ( ); // Read a JSON(C) or YAML file and return the object -const readConfig = (fs, dir, name, otherwise) => { +const readConfig = (fs, dir, name, otherwise) => () => { const file = pathPosix.join(dir, name); - return () => fs.promises.access(file). + return fs.promises.access(file). then( () => markdownlintReadConfig( file, @@ -125,9 +125,9 @@ const importOrRequireIdsAndParams = (dirs, idsAndParams, noRequire) => ( ); // Import or require a JavaScript file and return the exported object -const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => { +const importOrRequireConfig = (fs, dir, name, noRequire, otherwise) => () => { const id = pathPosix.join(dir, name); - return () => fs.promises.access(id). + return fs.promises.access(id). then( () => (noRequire ? {} : importOrRequireResolve([ dir ], id)), otherwise