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:
authorisaacs <i@izs.me>2020-07-11 04:19:53 +0300
committerisaacs <i@izs.me>2020-07-29 21:53:10 +0300
commite46400c9484f5c66a0ba405eeb8c1340594dbf05 (patch)
tree1c3c13d9024752c4b3dc129e2f86c7963544c5a4 /node_modules/read-cmd-shim
parent73657ae140810da50847d0ff729ddbab99ba5aac (diff)
update dependencies, refactor config loading to async
This removes a lot of very outdated dependencies, updates many to their modern (usually promisified) versions, and updates (or removes) code to account for the change. Several dependencies have been completely removed, and others a bit shuffled around, so that the node_modules folder can be bundled somewhat more optimally than it would have otherwise.
Diffstat (limited to 'node_modules/read-cmd-shim')
-rw-r--r--node_modules/read-cmd-shim/README.md11
-rw-r--r--node_modules/read-cmd-shim/index.js54
-rw-r--r--node_modules/read-cmd-shim/package.json52
3 files changed, 59 insertions, 58 deletions
diff --git a/node_modules/read-cmd-shim/README.md b/node_modules/read-cmd-shim/README.md
index b139ea7ff..457e36e35 100644
--- a/node_modules/read-cmd-shim/README.md
+++ b/node_modules/read-cmd-shim/README.md
@@ -7,18 +7,18 @@ is pointing at. This acts as the equivalent of
### Usage
```
-var readCmdShim = require('read-cmd-shim')
+const readCmdShim = require('read-cmd-shim')
-readCmdShim('/path/to/shim.cmd', function (er, destination) {
+readCmdShim('/path/to/shim.cmd').then(destination => {
})
-var destination = readCmdShim.sync('/path/to/shim.cmd')
+const destination = readCmdShim.sync('/path/to/shim.cmd')
```
-### readCmdShim(path, callback)
+### readCmdShim(path) -> Promise
-Reads the `cmd-shim` located at `path` and calls back with the _relative_
+Reads the `cmd-shim` located at `path` and resolves with the _relative_
path that the shim points at. Consider this as roughly the equivalent of
`fs.readlink`.
@@ -31,7 +31,6 @@ return a special `ENOTASHIM` exception, when it can't find a cmd-shim in the
file referenced by `path`. This should only happen if you pass in a
non-command shim.
-
### readCmdShim.sync(path)
Same as above but synchronous. Errors are thrown.
diff --git a/node_modules/read-cmd-shim/index.js b/node_modules/read-cmd-shim/index.js
index 3af2512f6..4ac050fc3 100644
--- a/node_modules/read-cmd-shim/index.js
+++ b/node_modules/read-cmd-shim/index.js
@@ -1,7 +1,9 @@
-'use strict'
-var fs = require('graceful-fs')
+const fs = require('fs')
+const {promisify} = require('util')
+const {readFileSync} = fs
+const readFile = promisify(fs.readFile)
-function extractPath (path, cmdshimContents) {
+const extractPath = (path, cmdshimContents) => {
if (/[.]cmd$/.test(path)) {
return extractPathFromCmd(cmdshimContents)
} else if (/[.]ps1$/.test(path)) {
@@ -11,51 +13,57 @@ function extractPath (path, cmdshimContents) {
}
}
-function extractPathFromPowershell (cmdshimContents) {
- var matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+[$]args/)
+const extractPathFromPowershell = cmdshimContents => {
+ const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+[$]args/)
return matches && matches[1]
}
-function extractPathFromCmd (cmdshimContents) {
- var matches = cmdshimContents.match(/"%(?:~dp0|dp0%)\\([^"]+?)"\s+%[*]/)
+const extractPathFromCmd = cmdshimContents => {
+ const matches = cmdshimContents.match(/"%(?:~dp0|dp0%)\\([^"]+?)"\s+%[*]/)
return matches && matches[1]
}
-function extractPathFromCygwin (cmdshimContents) {
- var matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/)
+const extractPathFromCygwin = cmdshimContents => {
+ const matches = cmdshimContents.match(/"[$]basedir[/]([^"]+?)"\s+"[$]@"/)
return matches && matches[1]
}
-function wrapError (thrown, newError) {
+const wrapError = (thrown, newError) => {
newError.message = thrown.message
newError.code = thrown.code
+ newError.path = thrown.path
return newError
}
-function notaShim (path, er) {
+const notaShim = (path, er) => {
if (!er) {
er = new Error()
Error.captureStackTrace(er, notaShim)
}
er.code = 'ENOTASHIM'
- er.message = "Can't read shim path from '" + path + "', it doesn't appear to be a cmd-shim"
+ er.message = `Can't read shim path from '${path}', ` +
+ `it doesn't appear to be a cmd-shim`
return er
}
-var readCmdShim = module.exports = function (path, cb) {
- var er = new Error()
+const readCmdShim = path => {
+ // create a new error to capture the stack trace from this point,
+ // instead of getting some opaque stack into node's internals
+ const er = new Error()
Error.captureStackTrace(er, readCmdShim)
- fs.readFile(path, function (readFileEr, contents) {
- if (readFileEr) return cb(wrapError(readFileEr, er))
- var destination = extractPath(path, contents.toString())
- if (destination) return cb(null, destination)
- return cb(notaShim(path, er))
- })
+ return readFile(path).then(contents => {
+ const destination = extractPath(path, contents.toString())
+ if (destination) return destination
+ return Promise.reject(notaShim(path, er))
+ }, readFileEr => Promise.reject(wrapError(readFileEr, er)))
}
-module.exports.sync = function (path) {
- var contents = fs.readFileSync(path)
- var destination = extractPath(path, contents.toString())
+const readCmdShimSync = path => {
+ const contents = readFileSync(path)
+ const destination = extractPath(path, contents.toString())
if (!destination) throw notaShim(path)
return destination
}
+
+readCmdShim.sync = readCmdShimSync
+module.exports = readCmdShim
diff --git a/node_modules/read-cmd-shim/package.json b/node_modules/read-cmd-shim/package.json
index 101651109..60e75647e 100644
--- a/node_modules/read-cmd-shim/package.json
+++ b/node_modules/read-cmd-shim/package.json
@@ -1,48 +1,37 @@
{
- "_from": "read-cmd-shim@1.0.5",
- "_id": "read-cmd-shim@1.0.5",
+ "_from": "read-cmd-shim@*",
+ "_id": "read-cmd-shim@2.0.0",
"_inBundle": false,
- "_integrity": "sha512-v5yCqQ/7okKoZZkBQUAfTsQ3sVJtXdNfbPnI5cceppoxEVLYA3k+VtV2omkeo8MS94JCy4fSiUwlRBAwCVRPUA==",
+ "_integrity": "sha512-HJpV9bQpkl6KwjxlJcBoqu9Ba0PQg8TqSNIOrulGt54a0uup0HtevreFHzYzkm0lpnleRdNBzXznKrgxglEHQw==",
"_location": "/read-cmd-shim",
"_phantomChildren": {},
"_requested": {
- "type": "version",
+ "type": "range",
"registry": true,
- "raw": "read-cmd-shim@1.0.5",
+ "raw": "read-cmd-shim@*",
"name": "read-cmd-shim",
"escapedName": "read-cmd-shim",
- "rawSpec": "1.0.5",
+ "rawSpec": "*",
"saveSpec": null,
- "fetchSpec": "1.0.5"
+ "fetchSpec": "*"
},
"_requiredBy": [
- "#USER",
- "/",
- "/gentle-fs"
+ "/"
],
- "_resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-1.0.5.tgz",
- "_shasum": "87e43eba50098ba5a32d0ceb583ab8e43b961c16",
- "_spec": "read-cmd-shim@1.0.5",
- "_where": "/Users/ruyadorno/Documents/workspace/cli",
- "author": {
- "name": "Rebecca Turner",
- "email": "me@re-becca.org",
- "url": "http://re-becca.org/"
- },
+ "_resolved": "https://registry.npmjs.org/read-cmd-shim/-/read-cmd-shim-2.0.0.tgz",
+ "_shasum": "4a50a71d6f0965364938e9038476f7eede3928d9",
+ "_spec": "read-cmd-shim@*",
+ "_where": "/Users/isaacs/dev/npm/cli",
"bugs": {
"url": "https://github.com/npm/read-cmd-shim/issues"
},
"bundleDependencies": false,
- "dependencies": {
- "graceful-fs": "^4.1.2"
- },
"deprecated": false,
"description": "Figure out what a cmd-shim is pointing at. This acts as the equivalent of fs.readlink.",
"devDependencies": {
- "cmd-shim": "^3.0.0",
- "rimraf": "^2.4.3",
- "standard": "^5.2.2",
- "tap": "^12.7.0"
+ "cmd-shim": "^4.0.0",
+ "rimraf": "^3.0.0",
+ "tap": "^14.10.6"
},
"files": [
"index.js"
@@ -56,8 +45,13 @@
"url": "git+https://github.com/npm/read-cmd-shim.git"
},
"scripts": {
- "pretest": "standard",
- "test": "tap test/*.js --100"
+ "postversion": "npm publish",
+ "prepublishOnly": "git push --follow-tags",
+ "preversion": "npm t",
+ "test": "tap"
+ },
+ "tap": {
+ "check-coverage": true
},
- "version": "1.0.5"
+ "version": "2.0.0"
}