@pob/pretty-pkg

12.2.0 • Public • Published

@pob/pretty-pkg

prettier and sort package.json

npm version npm downloads node version types

Install

npm install --save @pob/pretty-pkg

Usage

Bin

directly

yarn pretty-pkg package.json

with lint-staged

{
  "lint-staged": {
    "package.json": ["pretty-pkg"]
  }
}

Lib

overrideSync

const { overrideSync } = require("@pob/pretty-pkg");

overrideSync("package.json");

writeSync

const fs = require("fs");
const { writeSync } = require("@pob/pretty-pkg");

const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
writeSync(pkg, "package.json");

default

const fs = require("fs");
const prettyPkg = require("@pob/pretty-pkg");

// parsing yourself
const pkg = JSON.parse(fs.readFileSync("package.json", "utf-8"));
fs.writeFileSync(prettyPkg(pkg), "package.json");

// let prettyPkg parse
const pkgContent = fs.readFileSync("package.json", "utf-8");
fs.writeFileSync(prettyPkg(pkgContent), "package.json");

Readme

Keywords

none

Package Sidebar

Install

npm i @pob/pretty-pkg

Weekly Downloads

695

Version

12.2.0

License

ISC

Unpacked Size

25.1 kB

Total Files

6

Last publish

Collaborators

  • churpeau