From 06090e27d33d163445e0252015e6e41f0c58af40 Mon Sep 17 00:00:00 2001 From: anon Date: Sun, 15 Jan 2023 19:24:20 +0100 Subject: [PATCH] update .gitignore --- node_modules/.bin/curl-headers-to-json | 1 - node_modules/.package-lock.json | 15 ----- node_modules/curl-headers-to-json/README.md | 12 ---- node_modules/curl-headers-to-json/index.js | 56 ------------------- .../curl-headers-to-json/package.json | 18 ------ package-lock.json | 20 ------- 6 files changed, 122 deletions(-) delete mode 120000 node_modules/.bin/curl-headers-to-json delete mode 100644 node_modules/.package-lock.json delete mode 100644 node_modules/curl-headers-to-json/README.md delete mode 100755 node_modules/curl-headers-to-json/index.js delete mode 100644 node_modules/curl-headers-to-json/package.json delete mode 100644 package-lock.json diff --git a/node_modules/.bin/curl-headers-to-json b/node_modules/.bin/curl-headers-to-json deleted file mode 120000 index a825016..0000000 --- a/node_modules/.bin/curl-headers-to-json +++ /dev/null @@ -1 +0,0 @@ -../curl-headers-to-json/index.js \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json deleted file mode 100644 index 38e7954..0000000 --- a/node_modules/.package-lock.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "shallot", - "lockfileVersion": 3, - "requires": true, - "packages": { - "node_modules/curl-headers-to-json": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/curl-headers-to-json/-/curl-headers-to-json-1.0.1.tgz", - "integrity": "sha512-PNbfCuu4UdsTmSAHwN4R0m34KzvOvDjP3mJ6XNfHzOdeTskUb/eaVV110y/SnT6h6HDA7fisCNgQvRP/vH9obQ==", - "bin": { - "curl-headers-to-json": "index.js" - } - } - } -} diff --git a/node_modules/curl-headers-to-json/README.md b/node_modules/curl-headers-to-json/README.md deleted file mode 100644 index c9a3844..0000000 --- a/node_modules/curl-headers-to-json/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# curl-headers-to-json - -A tool to format the output of cURL headers into JSON. - -Example: -``` -curl -sSL -D - https://api.github.com -o /dev/null | npx curl-headers-to-json | jq -``` -or if you grabbed the output already: -``` -npx curl-headers-to-json headers.txt | jq -``` \ No newline at end of file diff --git a/node_modules/curl-headers-to-json/index.js b/node_modules/curl-headers-to-json/index.js deleted file mode 100755 index a40f52d..0000000 --- a/node_modules/curl-headers-to-json/index.js +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env node - -const fs = require('fs'); -const util = require('util'); -const readFile = util.promisify(fs.readFile); -const args = process.argv.slice(2); -const shellParam = args[0]; - -const isTTY = process.stdin.isTTY; -const stdin = process.stdin; -const stdout = process.stdout; - -if (isTTY && args.length === 0) { - console.log('Usage: '); -} else if (isTTY && args.length !== 0) { - handleShellArguments(); -} else { - handleStdin(); -} - -function handleStdin() { - let headersData = ''; - - stdin.setEncoding('utf8'); - stdin.on('readable', () => { - const chuck = stdin.read(); - if(chuck !== null){ - headersData += chuck; - } - }); - stdin.on('end', () => process.stdout.write(JSON.stringify(format(headersData)))); -} - - -function format(data) { - const lines = data.split(/\r?\n|\r/g); - const result = {}; - lines.shift(); - for(let line of lines) { - if(line.trim() === '') { - continue; - } - const [key, value] = line.split(': '); - result[key] = value.replace(/\\r/g, ''); - } - return result; -} - -async function handleShellArguments(){ - try { - const input = await readFile(shellParam, { encoding: 'utf8' }); - process.stdout.write(JSON.stringify(format(input))) - } catch (e) { - console.log(`An error ocurred while trying to open the file: ${e.message}`); - } -} \ No newline at end of file diff --git a/node_modules/curl-headers-to-json/package.json b/node_modules/curl-headers-to-json/package.json deleted file mode 100644 index 107c206..0000000 --- a/node_modules/curl-headers-to-json/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "curl-headers-to-json", - "bin": { - "curl-headers-to-json": "./index.js" - }, - "version": "1.0.1", - "description": "Formats cURL headers into JSON format", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 0" - }, - "keywords": [ - "curl", - "json" - ], - "author": "Alejandro Oviedo ", - "license": "MIT" -} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 6d7c8eb..0000000 --- a/package-lock.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "shallot", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "dependencies": { - "curl-headers-to-json": "^1.0.1" - } - }, - "node_modules/curl-headers-to-json": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/curl-headers-to-json/-/curl-headers-to-json-1.0.1.tgz", - "integrity": "sha512-PNbfCuu4UdsTmSAHwN4R0m34KzvOvDjP3mJ6XNfHzOdeTskUb/eaVV110y/SnT6h6HDA7fisCNgQvRP/vH9obQ==", - "bin": { - "curl-headers-to-json": "index.js" - } - } - } -}