Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@11ty/eleventy-fetch

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@11ty/eleventy-fetch - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

8

package.json
{
"name": "@11ty/eleventy-fetch",
"version": "3.0.0",
"version": "4.0.0",
"description": "Fetch and locally cache remote API calls and assets.",

@@ -22,3 +22,3 @@ "publishConfig": {

"engines": {
"node": ">=12"
"node": ">=14"
},

@@ -44,6 +44,6 @@ "funding": {

"devDependencies": {
"ava": "^4.0.1"
"ava": "^5.2.0"
},
"dependencies": {
"debug": "^4.3.3",
"debug": "^4.3.4",
"flat-cache": "^3.0.4",

@@ -50,0 +50,0 @@ "node-fetch": "^2.6.7",

@@ -1,6 +0,6 @@

<p align="center"><img src="https://www.11ty.dev/img/logo-github.png" alt="eleventy Logo"></p>
<p align="center"><img src="https://www.11ty.dev/img/logo-github.svg" width="200" height="200" alt="eleventy Logo"></p>
# eleventy-fetch
_Requires Node 12+_
_Requires Node 14+_

@@ -7,0 +7,0 @@ Formerly known as [`@11ty/eleventy-cache-assets`](https://www.npmjs.com/package/@11ty/eleventy-cache-assets).

@@ -125,2 +125,7 @@ const fs = require("fs");

async save(contents, type = "buffer") {
if(this.options.dryRun) {
debug("An attempt was made to save to the file system with `dryRun: true`. Skipping.");
return;
}
await this.ensureDir();

@@ -127,0 +132,0 @@

@@ -62,6 +62,6 @@ const fs = require("fs");

async fetch(optionsOverride = {}) {
let isDryRun = optionsOverride.dryRun || this.options.dryRun;
let duration = optionsOverride.duration || this.options.duration;
// Important: no disk writes/reads when dryRun
if( !isDryRun && super.isCacheValid(duration) ) {
// Important: no disk writes when dryRun
// As of Fetch v4, reads are now allowed!
if(super.isCacheValid(duration) ) {
return super.getCachedValue();

@@ -71,6 +71,9 @@ }

try {
let isDryRun = optionsOverride.dryRun || this.options.dryRun;
this.log( `[11ty/eleventy-fetch] ${isDryRun? "Fetching" : "Caching"}: ${this.displayUrl}` );
let fetchOptions = optionsOverride.fetchOptions || this.options.fetchOptions || {};
let response = await fetch(this.url, fetchOptions);
if(!response.ok) {
throw new Error(`Bad response for ${this.displayUrl} (${response.status}): ${response.statusText}`)
throw new Error(`Bad response for ${this.displayUrl} (${response.status}): ${response.statusText}`, { cause: response });
}

@@ -80,3 +83,2 @@

let body = await this.getResponseValue(response, type);
this.log( `[11ty/eleventy-fetch] ${isDryRun? "Fetching" : "Caching"}: ${this.displayUrl}` );
if(!isDryRun) {

@@ -83,0 +85,0 @@ await super.save(body, type);

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