cacache 11.1.0 → 11.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/lib/content/read.js +30 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
<a name="11.2.0"></a>
|
|
6
|
+
# [11.2.0](https://github.com/zkat/cacache/compare/v11.1.0...v11.2.0) (2018-08-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **read:** add sync support to other internal read.js fns ([fe638b6](https://github.com/zkat/cacache/commit/fe638b6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
5
15
|
<a name="11.1.0"></a>
|
|
6
16
|
# [11.1.0](https://github.com/zkat/cacache/compare/v11.0.3...v11.1.0) (2018-08-01)
|
|
7
17
|
|
package/lib/content/read.js
CHANGED
|
@@ -73,8 +73,10 @@ function readStream (cache, integrity, opts) {
|
|
|
73
73
|
let copyFileAsync
|
|
74
74
|
if (fs.copyFile) {
|
|
75
75
|
module.exports.copy = copy
|
|
76
|
+
module.exports.copy.sync = copySync
|
|
76
77
|
copyFileAsync = BB.promisify(fs.copyFile)
|
|
77
78
|
}
|
|
79
|
+
|
|
78
80
|
function copy (cache, integrity, dest, opts) {
|
|
79
81
|
opts = ReadOpts(opts)
|
|
80
82
|
return withContentSri(cache, integrity, (cpath, sri) => {
|
|
@@ -82,11 +84,18 @@ function copy (cache, integrity, dest, opts) {
|
|
|
82
84
|
})
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
function copySync (cache, integrity, dest, opts) {
|
|
88
|
+
opts = ReadOpts(opts)
|
|
89
|
+
return withContentSriSync(cache, integrity, (cpath, sri) => {
|
|
90
|
+
return fs.copyFileSync(cpath, dest)
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
module.exports.hasContent = hasContent
|
|
86
95
|
function hasContent (cache, integrity) {
|
|
87
96
|
if (!integrity) { return BB.resolve(false) }
|
|
88
97
|
return withContentSri(cache, integrity, (cpath, sri) => {
|
|
89
|
-
return lstatAsync(cpath).then(stat => ({size: stat.size, sri}))
|
|
98
|
+
return lstatAsync(cpath).then(stat => ({size: stat.size, sri, stat}))
|
|
90
99
|
}).catch(err => {
|
|
91
100
|
if (err.code === 'ENOENT') { return false }
|
|
92
101
|
if (err.code === 'EPERM') {
|
|
@@ -99,6 +108,26 @@ function hasContent (cache, integrity) {
|
|
|
99
108
|
})
|
|
100
109
|
}
|
|
101
110
|
|
|
111
|
+
module.exports.hasContent.sync = hasContentSync
|
|
112
|
+
function hasContentSync (cache, integrity) {
|
|
113
|
+
if (!integrity) { return false }
|
|
114
|
+
return withContentSriSync(cache, integrity, (cpath, sri) => {
|
|
115
|
+
try {
|
|
116
|
+
const stat = fs.lstatSync(cpath)
|
|
117
|
+
return {size: stat.size, sri, stat}
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (err.code === 'ENOENT') { return false }
|
|
120
|
+
if (err.code === 'EPERM') {
|
|
121
|
+
if (process.platform !== 'win32') {
|
|
122
|
+
throw err
|
|
123
|
+
} else {
|
|
124
|
+
return false
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
102
131
|
function withContentSri (cache, integrity, fn) {
|
|
103
132
|
return BB.try(() => {
|
|
104
133
|
const sri = ssri.parse(integrity)
|