Socket
Socket
Sign inDemoInstall

@netlify/cache-utils

Package Overview
Dependencies
Maintainers
18
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/cache-utils - npm Package Compare versions

Comparing version 5.0.2 to 5.1.0

31

lib/fs.js

@@ -7,3 +7,5 @@ import { promises as fs } from 'fs';

import { moveFile } from 'move-file';
// Move or copy a cached file/directory from/to a local one
/**
* Move or copy a cached file/directory from/to a local one
*/
export const moveCacheFile = async function (src, dest, move) {

@@ -14,11 +16,18 @@ // Moving is faster but removes the source files locally

}
const { srcGlob, cwd } = await getSrcGlob(src);
return cpy(srcGlob, dirname(dest), { cwd, parents: true, overwrite: false });
const glob = await getSrcGlob(src);
if (glob) {
return cpy(glob.srcGlob, dirname(dest), { cwd: glob.cwd, parents: true, overwrite: false });
}
};
// Non-existing files and empty directories are always skipped
/**
* Non-existing files and empty directories are always skipped
*/
export const hasFiles = async function (src) {
const { srcGlob, cwd, isDir } = await getSrcGlob(src);
return srcGlob !== undefined && !(await isEmptyDir({ srcGlob, cwd, isDir }));
const glob = await getSrcGlob(src);
if (!glob) {
return false;
}
return glob.srcGlob !== undefined && !(await isEmptyDir({ srcGlob: glob.srcGlob, cwd: glob.cwd, isDir: glob.isDir }));
};
// Replicates what `cpy` is doing under the hood.
/** Replicates what `cpy` is doing under the hood. */
const isEmptyDir = async function ({ srcGlob, cwd, isDir }) {

@@ -32,7 +41,9 @@ if (!isDir) {

};
// Get globbing pattern with files to move/copy
/**
* Get globbing pattern with files to move/copy
*/
const getSrcGlob = async function (src) {
const srcStat = await getStat(src);
if (srcStat === undefined) {
return {};
return null;
}

@@ -47,3 +58,3 @@ const isDir = srcStat.isDirectory();

};
const getStat = async function (src) {
const getStat = async (src) => {
try {

@@ -50,0 +61,0 @@ return await fs.stat(src);

{
"name": "@netlify/cache-utils",
"version": "5.0.2",
"version": "5.1.0",
"description": "Utility for caching files in Netlify Build",

@@ -72,3 +72,3 @@ "type": "module",

},
"gitHead": "be9da6e85afa0223bdcd6d228c929f4372515538"
"gitHead": "e22d6106d734d2b4b7b49d2a2350be21913c0cbf"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc