Skip to content

Commit

Permalink
Refactor to defer (and avoid) a tiny amount of work in readConfig and…
Browse files Browse the repository at this point in the history
… importOrRequireConfig.
  • Loading branch information
DavidAnson committed Feb 2, 2024
1 parent 54b94b5 commit 2515ee2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions markdownlint-cli2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2515ee2

Please sign in to comment.