Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Karrys <luke@lukekarrys.com>2021-09-02 00:32:47 +0300
committerLuke Karrys <luke@lukekarrys.com>2021-09-02 00:32:47 +0300
commit033e948c95b3455812e03a860ad1bd96a635e7eb (patch)
treeff73d99442f235a12a0bbf6c99a5c2ba1629409f /node_modules
parent6125db545315da0217fe7b05062fd0a504c9a45b (diff)
deps: read-package-json@4.1.1
* feat: add types lookup * fix(man): don't lose relative man path
Diffstat (limited to 'node_modules')
-rw-r--r--node_modules/read-package-json/package.json10
-rw-r--r--node_modules/read-package-json/read-json.js51
2 files changed, 54 insertions, 7 deletions
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 <i@izs.me> (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)