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:
authorGar <gar+gh@danger.computer>2022-05-18 23:25:57 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-05-20 00:14:58 +0300
commit632ce87bbd23707cba2c49b95d5db755b3d68638 (patch)
tree23ad2e15c440eed6fde940f710803334802f1d70 /node_modules/cacache/lib/put.js
parentee3308a7a08799ec7e86237165ebaf278d9a4f9f (diff)
deps: cacache@16.1.0
* allow external integrity/size source
Diffstat (limited to 'node_modules/cacache/lib/put.js')
-rw-r--r--node_modules/cacache/lib/put.js35
1 files changed, 14 insertions, 21 deletions
diff --git a/node_modules/cacache/lib/put.js b/node_modules/cacache/lib/put.js
index eed51874f..9fc932d5f 100644
--- a/node_modules/cacache/lib/put.js
+++ b/node_modules/cacache/lib/put.js
@@ -14,20 +14,16 @@ const putOpts = (opts) => ({
module.exports = putData
-function putData (cache, key, data, opts = {}) {
+async function putData (cache, key, data, opts = {}) {
const { memoize } = opts
opts = putOpts(opts)
- return write(cache, data, opts).then((res) => {
- return index
- .insert(cache, key, res.integrity, { ...opts, size: res.size })
- .then((entry) => {
- if (memoize) {
- memo.put(cache, entry, data, opts)
- }
+ const res = await write(cache, data, opts)
+ const entry = await index.insert(cache, key, res.integrity, { ...opts, size: res.size })
+ if (memoize) {
+ memo.put(cache, entry, data, opts)
+ }
- return res.integrity
- })
- })
+ return res.integrity
}
module.exports.stream = putStream
@@ -68,17 +64,14 @@ function putStream (cache, key, opts = {}) {
// last but not least, we write the index and emit hash and size,
// and memoize if we're doing that
pipeline.push(new Flush({
- flush () {
+ async flush () {
if (!error) {
- return index
- .insert(cache, key, integrity, { ...opts, size })
- .then((entry) => {
- if (memoize && memoData) {
- memo.put(cache, entry, memoData, opts)
- }
- pipeline.emit('integrity', integrity)
- pipeline.emit('size', size)
- })
+ const entry = await index.insert(cache, key, integrity, { ...opts, size })
+ if (memoize && memoData) {
+ memo.put(cache, entry, memoData, opts)
+ }
+ pipeline.emit('integrity', integrity)
+ pipeline.emit('size', size)
}
},
}))