@netlify/cache-utils 6.0.2 → 6.0.4
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 +3 -3
- package/lib/fs.js +0 -1
- package/lib/manifest.js +3 -3
- package/lib/utils/cwd.js +6 -6
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -109,10 +109,10 @@ Current directory used to resolve relative paths.
|
|
|
109
109
|
`options`: `object`\
|
|
110
110
|
_Returns_: `Promise<Boolean>`
|
|
111
111
|
|
|
112
|
-
Restore a file/directory previously cached. Skipped if
|
|
113
|
-
cached yet.
|
|
112
|
+
Restore a file/directory previously cached. Skipped if it has not been cached yet.
|
|
114
113
|
|
|
115
|
-
Please be careful: this
|
|
114
|
+
Please be careful: if the file/directory was cached, this will delete local file/directory and replace it with cached
|
|
115
|
+
content.
|
|
116
116
|
|
|
117
117
|
Returns `false` if the file/directory was not cached yet. Returns `true` otherwise.
|
|
118
118
|
|
package/lib/fs.js
CHANGED
|
@@ -24,7 +24,6 @@ export const moveCacheFile = async function (src, dest, move = false) {
|
|
|
24
24
|
* Non-existing files and empty directories are always skipped
|
|
25
25
|
*/
|
|
26
26
|
export const hasFiles = async function (src) {
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
27
|
const { srcGlob, isDir, dest, ...options } = await getSrcAndDest(src, '');
|
|
29
28
|
return srcGlob !== undefined && !(await isEmptyDir(srcGlob, isDir, options));
|
|
30
29
|
};
|
package/lib/manifest.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, readFile, rm, writeFile } from 'fs/promises';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
2
3
|
import { dirname } from 'path';
|
|
3
|
-
import { pathExists } from 'path-exists';
|
|
4
4
|
import { getExpires, checkExpires } from './expire.js';
|
|
5
5
|
import { getHash } from './hash.js';
|
|
6
6
|
// Retrieve cache manifest of a file to cache, which contains the file/directory
|
|
@@ -16,7 +16,7 @@ export const getManifestInfo = async function ({ cachePath, move, ttl, digests }
|
|
|
16
16
|
};
|
|
17
17
|
// Whether the cache manifest has changed
|
|
18
18
|
const isIdentical = async function ({ hash, manifestPath, manifestString }) {
|
|
19
|
-
if (hash === undefined || !(
|
|
19
|
+
if (hash === undefined || !existsSync(manifestPath)) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
22
|
const oldManifestString = await readFile(manifestPath, 'utf8');
|
|
@@ -43,7 +43,7 @@ const CACHE_EXTENSION = '.netlify.cache.json';
|
|
|
43
43
|
// Check whether a file/directory is expired by checking its cache manifest
|
|
44
44
|
export const isExpired = async function (cachePath) {
|
|
45
45
|
const manifestPath = getManifestPath(cachePath);
|
|
46
|
-
if (!(
|
|
46
|
+
if (!existsSync(manifestPath)) {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
const { expires } = await readManifest(cachePath);
|
package/lib/utils/cwd.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { normalize } from 'path';
|
|
2
|
+
import { existsSync } from 'fs';
|
|
2
3
|
import process from 'process';
|
|
3
|
-
import { pathExists } from 'path-exists';
|
|
4
4
|
// Like `process.cwd()` but safer when current directory is wrong
|
|
5
|
-
export const safeGetCwd =
|
|
5
|
+
export const safeGetCwd = function (cwdOpt) {
|
|
6
6
|
try {
|
|
7
7
|
const cwd = getCwdValue(cwdOpt);
|
|
8
|
-
if (!(
|
|
9
|
-
return '';
|
|
8
|
+
if (!existsSync(cwd)) {
|
|
9
|
+
return Promise.resolve('');
|
|
10
10
|
}
|
|
11
|
-
return cwd;
|
|
11
|
+
return Promise.resolve(cwd);
|
|
12
12
|
}
|
|
13
13
|
catch {
|
|
14
|
-
return '';
|
|
14
|
+
return Promise.resolve('');
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
17
|
const getCwdValue = function (cwdOpt = process.cwd()) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/cache-utils",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.4",
|
|
4
4
|
"description": "Utility for caching files in Netlify Build",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/main.js",
|
|
@@ -56,17 +56,16 @@
|
|
|
56
56
|
"junk": "^4.0.0",
|
|
57
57
|
"locate-path": "^7.0.0",
|
|
58
58
|
"move-file": "^3.0.0",
|
|
59
|
-
"path-exists": "^5.0.0",
|
|
60
59
|
"readdirp": "^4.0.0"
|
|
61
60
|
},
|
|
62
61
|
"devDependencies": {
|
|
63
|
-
"@types/node": "^
|
|
62
|
+
"@types/node": "^18.19.111",
|
|
64
63
|
"tmp-promise": "^3.0.0",
|
|
65
64
|
"typescript": "^5.0.0",
|
|
66
|
-
"vitest": "^0.
|
|
65
|
+
"vitest": "^3.0.0"
|
|
67
66
|
},
|
|
68
67
|
"engines": {
|
|
69
68
|
"node": ">=18.14.0"
|
|
70
69
|
},
|
|
71
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "31fa4eac5a3edfceb5d9a5b16d806ff21f94c039"
|
|
72
71
|
}
|