Socket
Socket
Sign inDemoInstall

@helloample/netlify-plugin-redirects

Package Overview
Dependencies
25
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

15

index.js

@@ -5,5 +5,16 @@ // index.js

module.exports = {
onPreBuild: async ({ inputs }) => {
await new Parser(inputs.source, inputs.destination).perform();
onPreBuild: async ({ utils, inputs }) => {
try {
const parser = new Parser(inputs.source, inputs.destination);
if (await parser.perform()) {
const stats = parser.stats();
utils.status.show(stats);
console.log(stats.summary);
} else {
throw new Error("There was a problem.");
}
} catch (err) {
utils.build.failBuild(err.message);
}
},
};

@@ -15,10 +15,26 @@ const csv = require("csvtojson");

this.rows;
this.rowsProcessed = [];
}
stats() {
return {
title: "Redirects processed successfully",
summary: `Wrote ${this.rowsProcessed.length} redirect rules to ${this.dest}.`,
text: `In /_redirects:\n<ul>${this.rowsProcessed.map(
(row) => `<li>${row.toString()}</li>`
)}</ul>`,
};
}
async perform() {
const rows = await this.getRows();
fs.writeFile(this.dest, rows.join("\n"), (err) => {
if (err) return console.error(err);
console.log(`Wrote ${rows.length} redirect rules to ${this.dest}`);
await this.getRows().then((rows) => {
rows.forEach((row) => {
// TODO: determine context and filter rows accordingly
this.rowsProcessed.push(row);
});
});
await fs.writeFile(this.dest, this.rowsProcessed.join("\n"), (err) => {
if (err) throw new Error(err);
});
return this.rowsProcessed.length;
}

@@ -25,0 +41,0 @@

2

package.json
{
"name": "@helloample/netlify-plugin-redirects",
"version": "1.0.0",
"version": "1.0.1",
"description": "Read a CSV file, parse the rows and write them to `_redirects` _before_ Netlify processes your build.",

@@ -5,0 +5,0 @@ "main": "index.js",

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

# netlify-plugin-redirects-csv
# netlify-plugin-redirects
<img src="https://api.travis-ci.com/ample/netlify-plugin-redirects.svg?branch=main" />
[![build status](https://api.travis-ci.com/ample/netlify-plugin-redirects.svg)](https://travis-ci.com/github/ample/netlify-plugin-redirects) [![npm version](https://badge.fury.io/js/%40helloample%2Fnetlify-plugin-redirects.svg)](https://www.npmjs.com/package/@helloample/netlify-plugin-redirects)

@@ -5,0 +5,0 @@ Read a CSV file, parse the rows and write them to `_redirects` _before_ Netlify processes your build.

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