jason-formatter
Advanced tools
Comparing version 1.0.1 to 1.1.1
{ | ||
"name": "jason-formatter", | ||
"version": "1.0.1", | ||
"version": "1.1.1", | ||
"description": "A Command Line tool to format JSON", | ||
@@ -25,3 +25,14 @@ "main": "src/index.js", | ||
}, | ||
"homepage": "https://github.com/UltiRequiem/json-formatter#readme" | ||
"homepage": "https://github.com/UltiRequiem/json-formatter#readme", | ||
"devDependencies": { | ||
"eslint": "^7.31.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin": "^1.0.1", | ||
"eslint-plugin-import": "^2.23.4", | ||
"prettier": "^2.3.2", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"prettier-eslint": "^12.0.0", | ||
"prettier-plugin-jsdoc": "^0.3.23" | ||
} | ||
} |
# Jason | ||
A command line tool to format JSON. | ||
A Command Line tformatter for JSON files, zero dependencies. | ||
@@ -25,8 +25,8 @@ ![Cover](./assets/cover.png) | ||
// Good Old require | ||
const { format } = require("jason-formatter"); | ||
const { format } = require('jason-formatter'); | ||
// New Syntax | ||
import { format } from "jason-formatter"; | ||
import { format } from 'jason-formatter'; | ||
``` | ||
You can see an example of use in [test/formatter.js](./tests/formater.js). |
@@ -1,3 +0,7 @@ | ||
const fs = require("fs").promises; | ||
const fs = require('fs').promises; | ||
/** | ||
* @param {string} text | ||
* @returns {string} The formatted text | ||
*/ | ||
function format(text) { | ||
@@ -7,9 +11,11 @@ return JSON.stringify(JSON.parse(text), null, 4); | ||
/** @param {string} file */ | ||
async function writeFile(file) { | ||
if (!file) throw new Error("You have to pass a file!"); | ||
if (!file) throw new Error('You have to pass a file!'); | ||
const raw = await fs.readFile(file, "utf-8"); | ||
fs.writeFile(file, format(raw)).then(() => console.log("JSON Formated :)")); | ||
const raw = await fs.readFile(file, 'utf-8'); | ||
fs.writeFile(file, format(raw)).then(() => console.log('JSON Formated :)')); | ||
} | ||
/** Init Function: Start the process */ | ||
function init() { | ||
@@ -19,2 +25,3 @@ writeFile(process.argv[2]); | ||
// Export Init and format function. | ||
module.exports = { init, format }; |
@@ -12,2 +12,1 @@ { | ||
} | ||
@@ -1,2 +0,2 @@ | ||
const { format } = require("../src/index"); | ||
const { format } = require('../src/index'); | ||
@@ -3,0 +3,0 @@ const rawData = ` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
29375
10
79
9