write-pkg
Write a package.json file
Last updated 7 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm
$ cnpm install write-pkg 
SYNC missed versions from official npm registry.

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

Current Tags

  • 5.1.0                                ...           latest (3 years ago)

4 Versions

  • 5.1.0                                ...           3 years ago
  • 5.0.0                                ...           4 years ago
  • 4.0.0                                ...           6 years ago
  • 3.2.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2013 - present © cnpmjs.org