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:
-rw-r--r--node_modules/graceful-fs/graceful-fs.js94
-rw-r--r--node_modules/graceful-fs/package.json2
-rw-r--r--package-lock.json14
-rw-r--r--package.json2
4 files changed, 57 insertions, 55 deletions
diff --git a/node_modules/graceful-fs/graceful-fs.js b/node_modules/graceful-fs/graceful-fs.js
index e15042da9..1b0736c27 100644
--- a/node_modules/graceful-fs/graceful-fs.js
+++ b/node_modules/graceful-fs/graceful-fs.js
@@ -114,14 +114,13 @@ function patch (fs) {
return go$readFile(path, options, cb)
- function go$readFile (path, options, cb) {
+ function go$readFile (path, options, cb, attempts = 0) {
return fs$readFile(path, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readFile, [path, options, cb]])
+ enqueue([go$readFile, [path, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -135,14 +134,13 @@ function patch (fs) {
return go$writeFile(path, data, options, cb)
- function go$writeFile (path, data, options, cb) {
+ function go$writeFile (path, data, options, cb, attempts = 0) {
return fs$writeFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$writeFile, [path, data, options, cb]])
+ enqueue([go$writeFile, [path, data, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -157,14 +155,13 @@ function patch (fs) {
return go$appendFile(path, data, options, cb)
- function go$appendFile (path, data, options, cb) {
+ function go$appendFile (path, data, options, cb, attempts = 0) {
return fs$appendFile(path, data, options, function (err) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$appendFile, [path, data, options, cb]])
+ enqueue([go$appendFile, [path, data, options, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -178,49 +175,43 @@ function patch (fs) {
cb = flags
flags = 0
}
- return fs$copyFile(src, dest, flags, function (err) {
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([fs$copyFile, [src, dest, flags, cb]])
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- retry()
- }
- })
+ return go$copyFile(src, dest, flags, cb)
+
+ function go$copyFile (src, dest, flags, cb, attempts = 0) {
+ return fs$copyFile(src, dest, flags, function (err) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([go$copyFile, [src, dest, flags, cb], attempts + 1, err])
+ else {
+ if (typeof cb === 'function')
+ cb.apply(this, arguments)
+ }
+ })
+ }
}
var fs$readdir = fs.readdir
fs.readdir = readdir
function readdir (path, options, cb) {
- var args = [path]
- if (typeof options !== 'function') {
- args.push(options)
- } else {
- cb = options
- }
- args.push(go$readdir$cb)
-
- return go$readdir(args)
+ if (typeof options === 'function')
+ cb = options, options = null
- function go$readdir$cb (err, files) {
- if (files && files.sort)
- files.sort()
+ return go$readdir(path, options, cb)
- if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$readdir, [args]])
+ function go$readdir (path, options, cb, attempts = 0) {
+ return fs$readdir(path, options, function (err, files) {
+ if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
+ enqueue([go$readdir, [path, options, cb], attempts + 1, err])
+ else {
+ if (files && files.sort)
+ files.sort()
- else {
- if (typeof cb === 'function')
- cb.apply(this, arguments)
- retry()
- }
+ if (typeof cb === 'function')
+ cb.call(this, err, files)
+ }
+ })
}
}
- function go$readdir (args) {
- return fs$readdir.apply(fs, args)
- }
-
if (process.version.substr(0, 4) === 'v0.8') {
var legStreams = legacy(fs)
ReadStream = legStreams.ReadStream
@@ -343,14 +334,13 @@ function patch (fs) {
return go$open(path, flags, mode, cb)
- function go$open (path, flags, mode, cb) {
+ function go$open (path, flags, mode, cb, attempts = 0) {
return fs$open(path, flags, mode, function (err, fd) {
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE'))
- enqueue([go$open, [path, flags, mode, cb]])
+ enqueue([go$open, [path, flags, mode, cb], attempts + 1, err])
else {
if (typeof cb === 'function')
cb.apply(this, arguments)
- retry()
}
})
}
@@ -362,12 +352,24 @@ function patch (fs) {
function enqueue (elem) {
debug('ENQUEUE', elem[0].name, elem[1])
fs[gracefulQueue].push(elem)
+ retry()
}
function retry () {
+ if (fs[gracefulQueue].length === 0)
+ return
+
var elem = fs[gracefulQueue].shift()
if (elem) {
- debug('RETRY', elem[0].name, elem[1])
- elem[0].apply(null, elem[1])
+ const [fn, args, attempts, err] = elem
+ if (attempts < 10) {
+ debug('RETRY', fn.name, args, `ATTEMPT #${attempts}`)
+ fn.call(null, ...args, attempts)
+ } else {
+ const cb = args.pop()
+ if (typeof cb === 'function')
+ cb.call(null, err)
+ }
}
+ setImmediate(retry)
}
diff --git a/node_modules/graceful-fs/package.json b/node_modules/graceful-fs/package.json
index d73f971fc..accbf4c91 100644
--- a/node_modules/graceful-fs/package.json
+++ b/node_modules/graceful-fs/package.json
@@ -1,7 +1,7 @@
{
"name": "graceful-fs",
"description": "A drop-in replacement for fs, making various improvements.",
- "version": "4.2.6",
+ "version": "4.2.7",
"repository": {
"type": "git",
"url": "https://github.com/isaacs/node-graceful-fs"
diff --git a/package-lock.json b/package-lock.json
index 5f5e7758e..6da1a8051 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -100,7 +100,7 @@
"cli-table3": "^0.6.0",
"columnify": "~1.5.4",
"glob": "^7.1.7",
- "graceful-fs": "^4.2.6",
+ "graceful-fs": "^4.2.7",
"hosted-git-info": "^4.0.2",
"ini": "^2.0.0",
"init-package-json": "^2.0.3",
@@ -3465,9 +3465,9 @@
}
},
"node_modules/graceful-fs": {
- "version": "4.2.6",
- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
- "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==",
+ "version": "4.2.7",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.7.tgz",
+ "integrity": "sha512-b1suB8r7mlSJQIBs6typf13fz55WYPeE7/KYlQUvqB7E3hUkXhz4D8FVHkENHTqG8+mD2yyT9HgT5bNkGNiqeQ==",
"inBundle": true
},
"node_modules/har-schema": {
@@ -13040,9 +13040,9 @@
"dev": true
},
"graceful-fs": {
- "version": "4.2.6",
- "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz",
- "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ=="
+ "version": "4.2.7",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.7.tgz",
+ "integrity": "sha512-b1suB8r7mlSJQIBs6typf13fz55WYPeE7/KYlQUvqB7E3hUkXhz4D8FVHkENHTqG8+mD2yyT9HgT5bNkGNiqeQ=="
},
"har-schema": {
"version": "2.0.0",
diff --git a/package.json b/package.json
index 07fb70f52..69de57eb2 100644
--- a/package.json
+++ b/package.json
@@ -70,7 +70,7 @@
"cli-table3": "^0.6.0",
"columnify": "~1.5.4",
"glob": "^7.1.7",
- "graceful-fs": "^4.2.6",
+ "graceful-fs": "^4.2.7",
"hosted-git-info": "^4.0.2",
"ini": "^2.0.0",
"init-package-json": "^2.0.3",