From 5787db8e4dbbdf19e94bd85ff83a99276588fd84 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Thu, 24 Jul 2025 15:52:01 +0100 Subject: [PATCH] chore: use empathic for traversal This library is much faster. In addition, it replaces _many_ packages which provide similar functionality outside of this repo. By using it here, we will benefit from npm's de-duplication on install because of that (e.g. in Netlify we dropped 6 packages to use this 1). --- index.js | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 0c8c05e..690a14a 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,7 @@ const fs = require('fs'); const path = require('path'); const {promisify} = require('util'); const camelcase = require('camelcase'); -const findUp = require('find-up'); +const {file: findUp, any: findAnyUp} = require('empathic/find'); const resolveFrom = require('resolve-from'); const getPackageType = require('get-package-type'); @@ -37,7 +37,7 @@ function camelcasedConfig(config) { async function findPackage(options) { const cwd = options.cwd || process.env.NYC_CWD || process.cwd(); - const pkgPath = await findUp('package.json', {cwd}); + const pkgPath = findUp('package.json', {cwd}); if (pkgPath) { const pkgConfig = JSON.parse(await readFile(pkgPath, 'utf8')).nyc || {}; if ('cwd' in pkgConfig) { @@ -139,7 +139,7 @@ async function applyExtends(config, filename, loopCheck = new Set()) { async function loadNycConfig(options = {}) { const {cwd, pkgConfig} = await findPackage(options); const configFiles = [].concat(options.nycrcPath || standardConfigFiles); - const configFile = await findUp(configFiles, {cwd}); + const configFile = findAnyUp(configFiles, {cwd}); if (options.nycrcPath && !configFile) { throw new Error(`Requested configuration file ${options.nycrcPath} not found`); } diff --git a/package.json b/package.json index 53207ef..5e30f2d 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "homepage": "https://github.com/istanbuljs/load-nyc-config#readme", "dependencies": { "camelcase": "^5.3.1", - "find-up": "^4.1.0", + "empathic": "^2.0.0", "get-package-type": "^0.1.0", "js-yaml": "^3.13.1", "resolve-from": "^5.0.0"