@netlify/cache-utils
Advanced tools
Comparing version 1.0.1 to 1.0.2-0
{ | ||
"name": "@netlify/cache-utils", | ||
"version": "1.0.1", | ||
"version": "1.0.2-0", | ||
"description": "Utility for caching files in Netlify Build", | ||
@@ -16,2 +16,33 @@ "main": "src/main.js", | ||
}, | ||
"keywords": [ | ||
"nodejs", | ||
"javascript", | ||
"windows", | ||
"macos", | ||
"linux", | ||
"shell", | ||
"bash", | ||
"build", | ||
"terminal", | ||
"deployment", | ||
"es6", | ||
"serverless", | ||
"continuous-integration", | ||
"continuous-delivery", | ||
"ci", | ||
"continuous-deployment", | ||
"plugins", | ||
"continuous-testing", | ||
"netlify-plugin", | ||
"netlify" | ||
], | ||
"homepage": "https://github.com/netlify/build", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/netlify/build.git", | ||
"directory": "packages/cache-utils" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/netlify/build/issues" | ||
}, | ||
"license": "MIT", | ||
@@ -24,3 +55,5 @@ "dependencies": { | ||
"global-cache-dir": "^1.0.1", | ||
"globby": "^10.0.2", | ||
"locate-path": "^5.0.0", | ||
"make-dir": "^3.1.0", | ||
"move-file": "^1.2.0", | ||
@@ -32,8 +65,4 @@ "path-exists": "^4.0.0", | ||
"ava": "^2.4.0", | ||
"tmp-promise": "^2.0.2" | ||
"tmp-promise": "^3.0.0" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/netlify/build" | ||
}, | ||
"engines": { | ||
@@ -40,0 +69,0 @@ "node": ">=8.3.0" |
@@ -6,2 +6,3 @@ const { stat } = require('fs') | ||
const cpy = require('cpy') | ||
const globby = require('globby') | ||
const moveFile = require('move-file') | ||
@@ -18,17 +19,49 @@ | ||
const srcGlob = await getSrcGlob(src) | ||
return cpy(srcGlob, dirname(dest), { cwd: dirname(src), parents: true, overwrite: false }) | ||
const { srcGlob, cwd } = await getSrcGlob(src) | ||
return cpy(srcGlob, dirname(dest), { cwd, parents: true, overwrite: false }) | ||
} | ||
// Non-existing files and empty directories are always skipped | ||
const hasFiles = async function(src) { | ||
const { srcGlob, cwd, isDir } = await getSrcGlob(src) | ||
return srcGlob !== undefined && !(await isEmptyDir({ srcGlob, cwd, isDir })) | ||
} | ||
// Replicates what `cpy` is doing under the hood. | ||
const isEmptyDir = async function({ srcGlob, cwd, isDir }) { | ||
if (!isDir) { | ||
return false | ||
} | ||
const files = await globby(srcGlob, { cwd, ignoreJunk: true }) | ||
return files.length === 0 | ||
} | ||
// Get globbing pattern with files to move/copy | ||
const getSrcGlob = async function(src) { | ||
const stat = await getStat(src) | ||
if (stat === undefined) { | ||
return {} | ||
} | ||
const isDir = stat.isDirectory() | ||
const srcBasename = basename(src) | ||
const stat = await pStat(src) | ||
const cwd = dirname(src) | ||
if (stat.isDirectory()) { | ||
return `${srcBasename}/**` | ||
if (isDir) { | ||
return { srcGlob: `${srcBasename}/**`, cwd, isDir } | ||
} | ||
return srcBasename | ||
return { srcGlob: srcBasename, cwd, isDir } | ||
} | ||
module.exports = { moveCacheFile } | ||
const getStat = async function(src) { | ||
try { | ||
return await pStat(src) | ||
} catch (error) { | ||
return | ||
} | ||
} | ||
module.exports = { moveCacheFile, hasFiles } |
require('./utils/polyfills') | ||
const del = require('del') | ||
const pathExists = require('path-exists') | ||
const { getCacheDir } = require('./dir') | ||
const { moveCacheFile } = require('./fs') | ||
const { moveCacheFile, hasFiles } = require('./fs') | ||
const { list } = require('./list') | ||
@@ -19,3 +18,3 @@ const { getManifestInfo, writeManifest, removeManifest, isExpired } = require('./manifest') | ||
if (!(await pathExists(srcPath))) { | ||
if (!(await hasFiles(srcPath))) { | ||
return false | ||
@@ -40,3 +39,3 @@ } | ||
if (!(await pathExists(cachePath))) { | ||
if (!(await hasFiles(cachePath))) { | ||
return false | ||
@@ -59,3 +58,3 @@ } | ||
if (!(await pathExists(cachePath))) { | ||
if (!(await hasFiles(cachePath))) { | ||
return false | ||
@@ -74,3 +73,3 @@ } | ||
return (await pathExists(cachePath)) && !(await isExpired(cachePath)) | ||
return (await hasFiles(cachePath)) && !(await isExpired(cachePath)) | ||
} | ||
@@ -77,0 +76,0 @@ |
const { writeFile, readFile } = require('fs') | ||
const { dirname } = require('path') | ||
const { promisify } = require('util') | ||
const del = require('del') | ||
const makeDir = require('make-dir') | ||
const pathExists = require('path-exists') | ||
@@ -37,2 +39,3 @@ | ||
const writeManifest = async function({ manifestPath, manifestString }) { | ||
await makeDir(dirname(manifestPath)) | ||
await pWriteFile(manifestPath, manifestString) | ||
@@ -39,0 +42,0 @@ } |
@@ -0,1 +1,2 @@ | ||
const { normalize } = require('path') | ||
const process = require('process') | ||
@@ -21,5 +22,5 @@ | ||
const getCwdValue = function(cwdOpt = process.cwd()) { | ||
return cwdOpt | ||
return normalize(cwdOpt) | ||
} | ||
module.exports = { safeGetCwd } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
22611
396
0
11
+ Addedglobby@^10.0.2
+ Addedmake-dir@^3.1.0