| 'use strict' | ||
| const fs = require('fs/promises') | ||
| const path = require('path') | ||
| const tagContent = `Signature: 8a477f597d28d172789f06886806bc55 | ||
| # This file is a cache directory tag created by cacache. | ||
| # For information about cache directory tags, see https://bford.info/cachedir/ | ||
| ` | ||
| async function mkdir (cache) { | ||
| await fs.mkdir(cache, { recursive: true, owner: 'inherit' }) | ||
| await writeTag(cache) | ||
| } | ||
| async function writeTag (cache) { | ||
| try { | ||
| await fs.writeFile(path.join(cache, 'CACHEDIR.TAG'), tagContent, { flag: 'wx' }) | ||
| } catch (err) { | ||
| if (err.code !== 'EEXIST') { | ||
| throw err | ||
| } | ||
| } | ||
| } | ||
| module.exports = { | ||
| mkdir, | ||
| tagContent, | ||
| } |
@@ -13,2 +13,3 @@ 'use strict' | ||
| const ssri = require('ssri') | ||
| const cacheDir = require('../util/cache-dir') | ||
| const { tmpName } = require('../util/tmp') | ||
@@ -157,2 +158,3 @@ const fsm = require('fs-minipass') | ||
| const tmpTarget = tmpName(cache, opts.tmpPrefix) | ||
| await cacheDir.mkdir(cache) | ||
| await fs.mkdir(path.dirname(tmpTarget), { recursive: true }) | ||
@@ -159,0 +161,0 @@ return { |
@@ -16,2 +16,3 @@ 'use strict' | ||
| const { tmpName } = require('./util/tmp') | ||
| const cacheDir = require('./util/cache-dir') | ||
@@ -74,2 +75,3 @@ const contentPath = require('./content/path') | ||
| const target = tmpName(cache, opts.tmpPrefix) | ||
| await cacheDir.mkdir(cache) | ||
| await mkdir(path.dirname(target), { recursive: true }) | ||
@@ -126,2 +128,3 @@ return { | ||
| try { | ||
| await cacheDir.mkdir(cache) | ||
| await mkdir(path.dirname(bucket), { recursive: true }) | ||
@@ -128,0 +131,0 @@ const stringified = JSON.stringify(entry) |
+1
-0
@@ -30,3 +30,4 @@ 'use strict' | ||
| const paths = await glob(path.join(cache, '*(content-*|index-*)'), { silent: true, nosort: true }) | ||
| paths.push(path.join(cache, 'CACHEDIR.TAG')) | ||
| return Promise.all(paths.map((p) => rm(p, { recursive: true, force: true }))) | ||
| } |
+5
-1
@@ -7,2 +7,3 @@ 'use strict' | ||
| const path = require('path') | ||
| const cacheDir = require('./cache-dir') | ||
@@ -19,2 +20,3 @@ module.exports.mkdir = mktmpdir | ||
| const tmpDir = path.join(cache, 'tmp') | ||
| await cacheDir.mkdir(cache) | ||
| await fs.mkdir(tmpDir, { recursive: true, owner: 'inherit' }) | ||
@@ -33,3 +35,5 @@ // do not use path.join(), it drops the trailing / if tmpPrefix is unset | ||
| } | ||
| return withTempDir(path.join(cache, 'tmp'), cb, opts) | ||
| return cacheDir.mkdir(cache).then(() => | ||
| withTempDir(path.join(cache, 'tmp'), cb, opts) | ||
| ) | ||
| } |
+2
-2
| 'use strict' | ||
| const { | ||
| mkdir, | ||
| readFile, | ||
@@ -15,2 +14,3 @@ rm, | ||
| const index = require('./entry-index') | ||
| const cacheDir = require('./util/cache-dir') | ||
| const path = require('path') | ||
@@ -81,3 +81,3 @@ const ssri = require('ssri') | ||
| opts.log.silly('verify', 'fixing cache permissions') | ||
| await mkdir(cache, { recursive: true }) | ||
| await cacheDir.mkdir(cache) | ||
| return null | ||
@@ -84,0 +84,0 @@ } |
+2
-2
| { | ||
| "name": "cacache", | ||
| "version": "21.0.0", | ||
| "version": "21.0.1", | ||
| "cache-version": { | ||
@@ -61,3 +61,3 @@ "content": "2", | ||
| "devDependencies": { | ||
| "@npmcli/eslint-config": "^6.0.1", | ||
| "@npmcli/eslint-config": "^7.0.0", | ||
| "@npmcli/template-oss": "5.1.0", | ||
@@ -64,0 +64,0 @@ "tap": "^16.0.0" |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
64916
1.6%18
5.88%1288
2.71%10
25%