cacache 18.0.0 → 18.0.2

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/README.md CHANGED
@@ -53,7 +53,6 @@ just as easily be used on its own.
53
53
  const cacache = require('cacache')
54
54
  const fs = require('fs')
55
55
 
56
- const tarball = '/path/to/mytar.tgz'
57
56
  const cachePath = '/tmp/my-toy-cache'
58
57
  const key = 'my-unique-key-1234'
59
58
 
@@ -13,18 +13,20 @@ async function read (cache, integrity, opts = {}) {
13
13
  const { size } = opts
14
14
  const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
15
15
  // get size
16
- const stat = await fs.stat(cpath)
16
+ const stat = size ? { size } : await fs.stat(cpath)
17
17
  return { stat, cpath, sri }
18
18
  })
19
- if (typeof size === 'number' && stat.size !== size) {
20
- throw sizeError(size, stat.size)
21
- }
22
19
 
23
20
  if (stat.size > MAX_SINGLE_READ_SIZE) {
24
21
  return readPipeline(cpath, stat.size, sri, new Pipeline()).concat()
25
22
  }
26
23
 
27
24
  const data = await fs.readFile(cpath, { encoding: null })
25
+
26
+ if (stat.size !== data.length) {
27
+ throw sizeError(stat.size, data.length)
28
+ }
29
+
28
30
  if (!ssri.checkData(data, sri)) {
29
31
  throw integrityError(sri, cpath)
30
32
  }
@@ -55,13 +57,10 @@ function readStream (cache, integrity, opts = {}) {
55
57
  // Set all this up to run on the stream and then just return the stream
56
58
  Promise.resolve().then(async () => {
57
59
  const { stat, cpath, sri } = await withContentSri(cache, integrity, async (cpath, sri) => {
58
- // just stat to ensure it exists
59
- const stat = await fs.stat(cpath)
60
+ // get size
61
+ const stat = size ? { size } : await fs.stat(cpath)
60
62
  return { stat, cpath, sri }
61
63
  })
62
- if (typeof size === 'number' && size !== stat.size) {
63
- return stream.emit('error', sizeError(size, stat.size))
64
- }
65
64
 
66
65
  return readPipeline(cpath, stat.size, sri, stream)
67
66
  }).catch(err => stream.emit('error', err))
@@ -67,6 +67,7 @@ class CacacheWriteStream extends Flush {
67
67
  this.cache,
68
68
  this.opts
69
69
  )
70
+ this.handleContentP.catch(error => this.emit('error', error))
70
71
  }
71
72
  return this.inputStream.write(chunk, encoding, cb)
72
73
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "18.0.0",
3
+ "version": "18.0.2",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -16,7 +16,7 @@
16
16
  "snap": "tap",
17
17
  "coverage": "tap",
18
18
  "test-docker": "docker run -it --rm --name pacotest -v \"$PWD\":/tmp -w /tmp node:latest npm test",
19
- "lint": "eslint \"**/*.js\"",
19
+ "lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
20
20
  "npmclilint": "npmcli-lint",
21
21
  "lintfix": "npm run lint -- --fix",
22
22
  "postsnap": "npm run lintfix --",
@@ -50,7 +50,7 @@
50
50
  "glob": "^10.2.2",
51
51
  "lru-cache": "^10.0.1",
52
52
  "minipass": "^7.0.3",
53
- "minipass-collect": "^1.0.2",
53
+ "minipass-collect": "^2.0.1",
54
54
  "minipass-flush": "^1.0.5",
55
55
  "minipass-pipeline": "^1.2.4",
56
56
  "p-map": "^4.0.0",
@@ -60,7 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@npmcli/eslint-config": "^4.0.0",
63
- "@npmcli/template-oss": "4.18.0",
63
+ "@npmcli/template-oss": "4.21.3",
64
64
  "tap": "^16.0.0"
65
65
  },
66
66
  "engines": {
@@ -69,14 +69,8 @@
69
69
  "templateOSS": {
70
70
  "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
71
71
  "windowsCI": false,
72
- "version": "4.18.0",
73
- "publish": "true",
74
- "ciVersions": [
75
- "16.14.0",
76
- "16.x",
77
- "18.0.0",
78
- "18.x"
79
- ]
72
+ "version": "4.21.3",
73
+ "publish": "true"
80
74
  },
81
75
  "author": "GitHub Inc.",
82
76
  "tap": {