From 033e948c95b3455812e03a860ad1bd96a635e7eb Mon Sep 17 00:00:00 2001 From: Luke Karrys Date: Wed, 1 Sep 2021 14:32:47 -0700 Subject: deps: read-package-json@4.1.1 * feat: add types lookup * fix(man): don't lose relative man path --- node_modules/read-package-json/package.json | 10 ++++-- node_modules/read-package-json/read-json.js | 51 ++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 7 deletions(-) (limited to 'node_modules') diff --git a/node_modules/read-package-json/package.json b/node_modules/read-package-json/package.json index 5ca535cfd..fb263fd71 100644 --- a/node_modules/read-package-json/package.json +++ b/node_modules/read-package-json/package.json @@ -1,6 +1,6 @@ { "name": "read-package-json", - "version": "4.0.1", + "version": "4.1.1", "author": "Isaac Z. Schlueter (http://blog.izs.me/)", "description": "The thing npm uses to read package.json files with semantics and defaults and validation", "repository": { @@ -12,7 +12,7 @@ "prerelease": "npm t", "postrelease": "npm publish && git push --follow-tags", "release": "standard-version -s", - "test": "tap --nyc-arg=--all --coverage test/*.js --branches 68 --functions 83 --lines 76 --statements 77", + "test": "tap --nyc-arg=--all --coverage test/*.js", "npmclilint": "npmcli-lint", "lint": "npm run npmclilint -- --ignore-pattern test/fixtures \"*.*js\" \"test/**/*.*js\"", "lintfix": "npm run lint -- --fix", @@ -36,5 +36,11 @@ ], "engines": { "node": ">=10" + }, + "tap": { + "branches": 68, + "functions": 83, + "lines": 76, + "statements": 77 } } diff --git a/node_modules/read-package-json/read-json.js b/node_modules/read-package-json/read-json.js index 04d22e3af..468a33e39 100644 --- a/node_modules/read-package-json/read-json.js +++ b/node_modules/read-package-json/read-json.js @@ -21,6 +21,7 @@ readJson.extraSet = [ mans, bins, githead, + fillTypes, ] var typoWarned = {} @@ -339,16 +340,17 @@ function readme_ (file, data, rm, cb) { } function mans (file, data, cb) { - var m = data.directories && data.directories.man - if (data.man || !m) { + let cwd = data.directories && data.directories.man + if (data.man || !cwd) { return cb(null, data) } - m = path.resolve(path.dirname(file), m) - glob('**/*.[0-9]', { cwd: m }, function (er, mans) { + const dirname = path.dirname(file) + cwd = path.resolve(path.dirname(file), cwd) + glob('**/*.[0-9]', { cwd }, function (er, mans) { if (er) { return cb(er) } - data.man = mans + data.man = mans.map(man => path.relative(dirname, path.join(cwd, man))) return cb(null, data) }) } @@ -517,6 +519,45 @@ function final (file, data, log, strict, cb) { }) } +function fillTypes (file, data, cb) { + var index = data.main ? data.main : 'index.js' + + // TODO exports is much more complicated than this in verbose format + // We need to support for instance + + // "exports": { + // ".": [ + // { + // "default": "./lib/npm.js" + // }, + // "./lib/npm.js" + // ], + // "./package.json": "./package.json" + // }, + // as well as conditional exports + + // if (data.exports && typeof data.exports === 'string') { + // index = data.exports + // } + + // if (data.exports && data.exports['.']) { + // index = data.exports['.'] + // if (typeof index !== 'string') { + // } + // } + + var extless = + path.join(path.dirname(index), path.basename(index, path.extname(index))) + var dts = `./${extless}.d.ts` + var dtsPath = path.join(path.dirname(file), dts) + var hasDTSFields = 'types' in data || 'typings' in data + if (!hasDTSFields && fs.existsSync(dtsPath)) { + data.types = dts + } + + cb(null, data) +} + function makePackageId (data) { var name = cleanString(data.name) var ver = cleanString(data.version) -- cgit v1.2.3