1
mirror of https://github.com/jakejarvis/netlify-plugin-cache.git synced 2025-04-26 02:55:22 -04:00

provide a default 'paths', needed to list in Netlify UI (closes #1)

This commit is contained in:
Jake Jarvis 2020-06-06 10:58:26 -04:00
parent e2ee0ba0e3
commit aac7ad188c
Signed by: jake
GPG Key ID: 2B0C9CF251E69A39
3 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,4 @@
# netlify-plugin-cache
# Netlify Plugin: Custom Cache
[![npm](https://img.shields.io/npm/v/netlify-plugin-cache?logo=npm&color=red)](https://www.npmjs.com/package/netlify-plugin-cache)
@ -18,7 +18,9 @@ package = "netlify-plugin-cache"
paths = ["resources", "_vendor", "folder/file.md"]
```
This plugin only takes one input (which is required) named `paths`, an array of paths to files and/or folders relative to your project's root. These files/folders are restored before a build and saved in cache after a build **if it is successful**.
This plugin only takes one input named `paths`, an array of files and/or directories relative to your project's root. These files/directories are restored before a build and saved in cache after a build **if it is successful**.
**🚨 Important:** `paths` defaults to `[".cache"]`, but it's **highly recommended** you set this yourself based on the tools you're using. See examples below.
Read more about plugin configuration at [the official Netlify Plugin docs](https://docs.netlify.com/configure-builds/build-plugins/#install-a-plugin).
@ -40,7 +42,7 @@ You can add their debug plugin **after** this plugin in your `netlify.toml`. (An
package = "netlify-plugin-debug-cache"
```
The plugin will generate a file named `cache-output.json` at the root of your project's publish directory. [Learn more about this plugin here.](https://github.com/netlify-labs/netlify-plugin-debug-cache)
The plugin will generate a file named `cache-output.json` at the root of your project's publish directory. [See an example file](https://gist.github.com/jakejarvis/dff606289e8b5d6be42d317e425bbee6#file-cache-output-json) or [learn more about this plugin](https://github.com/netlify-labs/netlify-plugin-debug-cache).
## Licenses

View File

@ -7,7 +7,7 @@ module.exports = {
const files = await cache.list(inputs.paths)
console.log(`Successfully restored: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
} else {
console.log(`A cache of ${inputs.paths.join(', ')} doesn't exist (yet).`)
console.log(`A cache of '${inputs.paths.join(', ')}' doesn't exist (yet).`)
}
},
@ -24,7 +24,10 @@ module.exports = {
text: `${inputs.paths.join(', ')}`,
})
} else {
console.log(`Failed caching ${inputs.paths.join(', ')}. :(`)
// this probably happened because the default `paths` is set, so provide instructions to fix
console.log(`Attempted to cache: ${inputs.paths.join(', ')} ... but failed. :(`)
console.log(`Try setting the 'paths' input appropriately in your netlify.toml or netlify.yml.`)
console.log(`More details: https://jrvs.io/netlify-cache-usage`)
}
},
}

View File

@ -2,4 +2,4 @@ name: netlify-plugin-cache
inputs:
- name: paths
description: Array of files and/or directories to cache between builds.
required: true
default: [".cache"]