cacache
Advanced tools
Comparing version 11.1.0 to 11.2.0
@@ -5,2 +5,12 @@ # Change Log | ||
<a name="11.2.0"></a> | ||
# [11.2.0](https://github.com/zkat/cacache/compare/v11.1.0...v11.2.0) (2018-08-08) | ||
### Features | ||
* **read:** add sync support to other internal read.js fns ([fe638b6](https://github.com/zkat/cacache/commit/fe638b6)) | ||
<a name="11.1.0"></a> | ||
@@ -7,0 +17,0 @@ # [11.1.0](https://github.com/zkat/cacache/compare/v11.0.3...v11.1.0) (2018-08-01) |
@@ -76,4 +76,6 @@ 'use strict' | ||
module.exports.copy = copy | ||
module.exports.copy.sync = copySync | ||
copyFileAsync = BB.promisify(fs.copyFile) | ||
} | ||
function copy (cache, integrity, dest, opts) { | ||
@@ -86,2 +88,9 @@ opts = ReadOpts(opts) | ||
function copySync (cache, integrity, dest, opts) { | ||
opts = ReadOpts(opts) | ||
return withContentSriSync(cache, integrity, (cpath, sri) => { | ||
return fs.copyFileSync(cpath, dest) | ||
}) | ||
} | ||
module.exports.hasContent = hasContent | ||
@@ -91,3 +100,3 @@ function hasContent (cache, integrity) { | ||
return withContentSri(cache, integrity, (cpath, sri) => { | ||
return lstatAsync(cpath).then(stat => ({size: stat.size, sri})) | ||
return lstatAsync(cpath).then(stat => ({size: stat.size, sri, stat})) | ||
}).catch(err => { | ||
@@ -105,2 +114,22 @@ if (err.code === 'ENOENT') { return false } | ||
module.exports.hasContent.sync = hasContentSync | ||
function hasContentSync (cache, integrity) { | ||
if (!integrity) { return false } | ||
return withContentSriSync(cache, integrity, (cpath, sri) => { | ||
try { | ||
const stat = fs.lstatSync(cpath) | ||
return {size: stat.size, sri, stat} | ||
} catch (err) { | ||
if (err.code === 'ENOENT') { return false } | ||
if (err.code === 'EPERM') { | ||
if (process.platform !== 'win32') { | ||
throw err | ||
} else { | ||
return false | ||
} | ||
} | ||
} | ||
}) | ||
} | ||
function withContentSri (cache, integrity, fn) { | ||
@@ -107,0 +136,0 @@ return BB.try(() => { |
{ | ||
"name": "cacache", | ||
"version": "11.1.0", | ||
"version": "11.2.0", | ||
"cache-version": { | ||
@@ -5,0 +5,0 @@ "content": "2", |
106685
1393