Skip to content

Commit aac7ad1

Browse files
committed
provide a default 'paths', needed to list in Netlify UI (closes #1)
1 parent e2ee0ba commit aac7ad1

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# netlify-plugin-cache
1+
# Netlify Plugin: Custom Cache
22

33
[![npm](https://img.shields.io/npm/v/netlify-plugin-cache?logo=npm&color=red)](https://www.npmjs.com/package/netlify-plugin-cache)
44

@@ -18,7 +18,9 @@ package = "netlify-plugin-cache"
1818
paths = ["resources", "_vendor", "folder/file.md"]
1919
```
2020

21-
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**.
21+
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**.
22+
23+
**🚨 Important:** `paths` defaults to `[".cache"]`, but it's **highly recommended** you set this yourself based on the tools you're using. See examples below.
2224

2325
Read more about plugin configuration at [the official Netlify Plugin docs](https://docs.netlify.com/configure-builds/build-plugins/#install-a-plugin).
2426

@@ -40,7 +42,7 @@ You can add their debug plugin **after** this plugin in your `netlify.toml`. (An
4042
package = "netlify-plugin-debug-cache"
4143
```
4244

43-
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)
45+
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).
4446

4547
## Licenses
4648

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
const files = await cache.list(inputs.paths)
88
console.log(`Successfully restored: ${inputs.paths.join(', ')} ... ${files.length} files in total.`)
99
} else {
10-
console.log(`A cache of ${inputs.paths.join(', ')} doesn't exist (yet).`)
10+
console.log(`A cache of '${inputs.paths.join(', ')}' doesn't exist (yet).`)
1111
}
1212
},
1313

@@ -24,7 +24,10 @@ module.exports = {
2424
text: `${inputs.paths.join(', ')}`,
2525
})
2626
} else {
27-
console.log(`Failed caching ${inputs.paths.join(', ')}. :(`)
27+
// this probably happened because the default `paths` is set, so provide instructions to fix
28+
console.log(`Attempted to cache: ${inputs.paths.join(', ')} ... but failed. :(`)
29+
console.log(`Try setting the 'paths' input appropriately in your netlify.toml or netlify.yml.`)
30+
console.log(`More details: https://jrvs.io/netlify-cache-usage`)
2831
}
2932
},
3033
}

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ name: netlify-plugin-cache
22
inputs:
33
- name: paths
44
description: Array of files and/or directories to cache between builds.
5-
required: true
5+
default: [".cache"]

0 commit comments

Comments
 (0)