New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@netlify/edge-bundler

Package Overview
Dependencies
Maintainers
19
Versions
137
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/edge-bundler - npm Package Compare versions

Comparing version 1.14.0 to 1.14.1

4

dist/downloader.d.ts
import { Logger } from './logger.js';
declare const download: (targetDirectory: string, versionRange: string, logger: Logger) => Promise<string>;
export { download };
declare const downloadWithRetry: (targetDirectory: string, versionRange: string, logger: Logger) => Promise<string>;
export { downloadWithRetry as download };

@@ -1,3 +0,4 @@

import fs from 'fs';
import { createWriteStream, promises as fs } from 'fs';
import path from 'path';
import { promisify } from 'util';
import fetch from 'node-fetch';

@@ -8,21 +9,33 @@ import StreamZip from 'node-stream-zip';

import { getBinaryExtension, getPlatformTarget } from './platform.js';
const download = async (targetDirectory, versionRange, logger) => {
const downloadWithRetry = async (targetDirectory, versionRange, logger) => await pRetry(async () => await download(targetDirectory, versionRange), {
retries: 3,
onFailedAttempt: (error) => {
logger.system('Deno download with retry failed', error);
},
});
const download = async (targetDirectory, versionRange) => {
const zipPath = path.join(targetDirectory, 'deno-cli-latest.zip');
const data = await downloadVersionWithRetry(versionRange, logger);
const data = await downloadVersion(versionRange);
const binaryName = `deno${getBinaryExtension()}`;
const binaryPath = path.join(targetDirectory, binaryName);
const file = fs.createWriteStream(zipPath);
await new Promise((resolve, reject) => {
data.pipe(file);
data.on('error', reject);
file.on('finish', resolve);
});
await extractBinaryFromZip(zipPath, binaryPath, binaryName);
const file = createWriteStream(zipPath);
try {
await fs.promises.unlink(zipPath);
await new Promise((resolve, reject) => {
data.pipe(file);
data.on('error', reject);
file.on('finish', resolve);
});
await extractBinaryFromZip(zipPath, binaryPath, binaryName);
return binaryPath;
}
catch {
// no-op
finally {
// Try closing and deleting the zip file in any case, error or not
await promisify(file.close.bind(file))();
try {
await fs.unlink(zipPath);
}
catch {
// no-op
}
}
return binaryPath;
};

@@ -33,13 +46,8 @@ const downloadVersion = async (versionRange) => {

const res = await fetch(url);
if (res.body === null) {
throw new Error('Could not download Deno');
// eslint-disable-next-line no-magic-numbers
if (res.body === null || res.status < 200 || res.status > 299) {
throw new Error(`Download failed with status code ${res.status}`);
}
return res.body;
};
const downloadVersionWithRetry = async (versionRange, logger) => await pRetry(async () => await downloadVersion(versionRange), {
retries: 3,
onFailedAttempt: (error) => {
logger.system('Deno CLI download retry attempt error', error);
},
});
const extractBinaryFromZip = async (zipPath, binaryPath, binaryName) => {

@@ -50,3 +58,3 @@ const { async: StreamZipAsync } = StreamZip;

await zip.close();
await fs.promises.chmod(binaryPath, '755');
await fs.chmod(binaryPath, '755');
};

@@ -88,2 +96,2 @@ const getLatestVersion = async () => {

};
export { download };
export { downloadWithRetry as download };
{
"name": "@netlify/edge-bundler",
"version": "1.14.0",
"version": "1.14.1",
"description": "Intelligently prepare Netlify Edge Functions for deployment",

@@ -5,0 +5,0 @@ "type": "module",

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