@netlify/cache-utils 5.1.4 → 5.1.5
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/lib/fs.js +9 -7
- package/package.json +3 -3
package/lib/fs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises as fs } from 'fs';
|
|
2
|
-
import { basename, dirname } from 'path';
|
|
2
|
+
import { basename, dirname, join } from 'path';
|
|
3
3
|
import cpy from 'cpy';
|
|
4
4
|
import { globby } from 'globby';
|
|
5
5
|
import { isNotJunk } from 'junk';
|
|
@@ -15,16 +15,17 @@ export const moveCacheFile = async function (src, dest, move = false) {
|
|
|
15
15
|
if (move) {
|
|
16
16
|
return moveFile(src, dest, { overwrite: false });
|
|
17
17
|
}
|
|
18
|
-
const { srcGlob, ...options } = await
|
|
19
|
-
if (srcGlob) {
|
|
20
|
-
return cpy(srcGlob,
|
|
18
|
+
const { srcGlob, dest: matchedDest, ...options } = await getSrcAndDest(src, dirname(dest));
|
|
19
|
+
if (srcGlob && matchedDest) {
|
|
20
|
+
return cpy(srcGlob, matchedDest, { ...options, overwrite: false });
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* Non-existing files and empty directories are always skipped
|
|
25
25
|
*/
|
|
26
26
|
export const hasFiles = async function (src) {
|
|
27
|
-
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
const { srcGlob, isDir, dest, ...options } = await getSrcAndDest(src, '');
|
|
28
29
|
return srcGlob !== undefined && !(await isEmptyDir(srcGlob, isDir, options));
|
|
29
30
|
};
|
|
30
31
|
/** Replicates what `cpy` is doing under the hood. */
|
|
@@ -39,7 +40,7 @@ const isEmptyDir = async function (globPattern, isDir, options) {
|
|
|
39
40
|
/**
|
|
40
41
|
* Get globbing pattern with files to move/copy
|
|
41
42
|
*/
|
|
42
|
-
const
|
|
43
|
+
const getSrcAndDest = async function (src, dest) {
|
|
43
44
|
const srcStat = await getStat(src);
|
|
44
45
|
if (srcStat === undefined) {
|
|
45
46
|
return { srcGlob: undefined, isDir: false, cwd: '' };
|
|
@@ -49,12 +50,13 @@ const getSrcGlob = async function (src) {
|
|
|
49
50
|
const cwd = dirname(src);
|
|
50
51
|
const baseOptions = {
|
|
51
52
|
srcGlob: srcBasename,
|
|
53
|
+
dest,
|
|
52
54
|
isDir,
|
|
53
55
|
cwd,
|
|
54
56
|
dot: true, // collect .dot directories as well
|
|
55
57
|
};
|
|
56
58
|
if (isDir) {
|
|
57
|
-
return { ...baseOptions, srcGlob: `${srcBasename}
|
|
59
|
+
return { ...baseOptions, srcGlob: `${srcBasename}/**`, dest: join(dest, srcBasename) };
|
|
58
60
|
}
|
|
59
61
|
return baseOptions;
|
|
60
62
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/cache-utils",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Utility for caching files in Netlify Build",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/main.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"license": "MIT",
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"cpy": "^
|
|
53
|
+
"cpy": "^9.0.0",
|
|
54
54
|
"get-stream": "^6.0.0",
|
|
55
55
|
"globby": "^13.0.0",
|
|
56
56
|
"junk": "^4.0.0",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"engines": {
|
|
69
69
|
"node": "^14.16.0 || >=16.0.0"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "6c093847fef2347fc80740059cbf0ee49ea193fc"
|
|
72
72
|
}
|