@afoot/write-json

0.1.3 • Public • Published

write-json

A JSON file-writing package designed for NPM initializers and places where Node needs to write static files.

installation

install: npm i --D @afoot/write-json

import: import writeJson from '@afoot/write-json'

documentation

write-json takes the following params:

  • filename | string name and extension of the file to be written
  • json | Object any valid JSON statement. Ideally object literals or arrays
  • config | Object configuration object (see below)

config object breakdown

{
 errorCallback: null, // Calls if file write fails
 willFormat: true, // Option to disable tab formatting
 root: `(current working directory)`, // File path to write
 writeOptions: {flag:'w'} // Node options object for `writeFile`
}

example

const obj = { name: 'test', version: '0.0.1' };
const filename = 'package.json';

writeJson(filename, obj);

license

MIT © Matthew Smith

made with ❤️ and ☕️ by

Niftiness Afoot! Matthew Smith

Package Sidebar

Install

npm i @afoot/write-json

Weekly Downloads

3

Version

0.1.3

License

MIT

Unpacked Size

6.57 kB

Total Files

5

Last publish

Collaborators

  • niftinessafoot