Denis 346b78aee1 first commit hace 2 años
..
node_modules 346b78aee1 first commit hace 2 años
index.d.ts 346b78aee1 first commit hace 2 años
index.js 346b78aee1 first commit hace 2 años
license 346b78aee1 first commit hace 2 años
package.json 346b78aee1 first commit hace 2 años
readme.md 346b78aee1 first commit hace 2 años

readme.md

write-pkg Build Status

Write a package.json file

Writes atomically and creates directories for you as needed. Sorts dependencies when writing. Preserves the indentation if the file already exists.

Install

$ npm install write-pkg

Usage

const path = require('path');
const writePackage = require('write-pkg');

(async () => {
	await writePackage({foo: true});
	console.log('done');

	await writePackage(__dirname, {foo: true});
	console.log('done');

	await writePackage(path.join('unicorn', 'package.json'), {foo: true});
	console.log('done');
})();

API

writePackage([path], data, [options])

Returns a Promise.

writePackage.sync([path], data, [options])

path

Type: string
Default: process.cwd()

Path to where the package.json file should be written or its directory.

options

Type: object

normalize

Type: boolean
Default: true

Remove empty dependencies, devDependencies, optionalDependencies and peerDependencies objects.

Related

License

MIT © Sindre Sorhus