Socket
Socket
Sign inDemoInstall

netlify-plugin-hugo-cache-resources

Package Overview
Dependencies
11
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

33

index.js
const { join } = require("path");
const glob = require("glob");
const getResourcesDir = ({ inputs }) => {
return join(inputs.srcdir, 'resources');
}
return join(inputs.srcdir, "resources");
};
const printList = (items) => {
console.log('---');
console.log("---");
items.forEach((item, index) => {
console.log(`${index + 1}. ${item}`);
});
}
};
module.exports = {
async onPreBuild({ utils, inputs }) {

@@ -23,3 +23,5 @@ const path = getResourcesDir({ inputs });

const cachedFiles = await utils.cache.list(path);
console.log(`Restored cached resources folder. Total files: ${cachedFiles.length}`);
console.log(
`Restored cached resources folder. Total files: ${cachedFiles.length}`
);
if (inputs.debug) printList(cachedFiles);

@@ -36,9 +38,18 @@ } else {

if (success) {
const cachedFiles = await utils.cache.list(path);
console.log(`Saved resources folder to cache. Total files: ${cachedFiles.length}`);
if (inputs.debug) printList(cachedFiles);
const cached = await utils.cache.list(path);
const files = [
...new Set(
cached.map((c) => glob.sync(`${c}/**/*`, { nodir: true })).flat()
),
];
console.log(
`Saved resources folder to cache. Total files: ${files.length}`
);
if (inputs.debug) {
printList(files);
}
} else {
console.log(`No resources folder cached`);
}
}
};
},
};
{
"name": "netlify-plugin-hugo-cache-resources",
"version": "0.2.0",
"version": "0.2.1",
"description": "Persist Hugo resources folder between Netlify builds for huge build speed improvements!",

@@ -16,3 +16,5 @@ "main": "index.js",

],
"dependencies": {}
"dependencies": {
"glob": "^7.1.7"
}
}

@@ -7,8 +7,8 @@ # Netlify Build Plugin: Persist Hugo resources Between Builds

Note: Restoring cache only comes from the production branch. So once cache is saved on the production branch, the next preview build would use the cache. For example, when pushing to the same preview build, the latest preview build will not get the cache from the previous preview build, but will get it from master.
## Usage
To install, add the following lines to your `netlify.toml` file:
You can install this plugin in the Netlify UI from this [direct in-app installation link](https://app.netlify.com/plugins/netlify-plugin-hugo-cache-resources/install) or from the [Plugins directory](https://app.netlify.com/plugins).
For file-based installation, add the following lines to your `netlify.toml` file:
```toml

@@ -28,2 +28,8 @@ [build]

Note: The `[[plugins]]` line is required for each plugin, even if you have other plugins in your `netlify.toml` file already.
Note: The `[[plugins]]` line is required for each plugin, even if you have other plugins in your `netlify.toml` file already.
To complete file-based installation, from your project's base directory, use npm, yarn, or any other Node.js package manager to add the plugin to `devDependencies` in `package.json`.
```bash
npm install -D netlify-plugin-hugo-cache-resources
```
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc