{"name":"write-pkg","version":"3.0.0","description":"Write a package.json file","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/write-pkg.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["json","write","stringify","file","fs","graceful","pkg","package"],"dependencies":{"sort-keys":"^1.1.2","write-json-file":"^2.0.0"},"devDependencies":{"ava":"*","read-pkg":"^2.0.0","tempfile":"^2.0.0","xo":"*"},"gitHead":"3b10e98079ba54dd6856e426ab689d93d3543655","bugs":{"url":"https://github.com/sindresorhus/write-pkg/issues"},"homepage":"https://github.com/sindresorhus/write-pkg#readme","_id":"write-pkg@3.0.0","_shasum":"58b9ce0d00f3e6f5d77204419b574b9ffb65f074","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"58b9ce0d00f3e6f5d77204419b574b9ffb65f074","tarball":"http://registry-npm.ywwl.com/write-pkg/download/write-pkg-3.0.0.tgz","integrity":"sha512-9b3C9hR63sngta4W37Or2hxdclf+6BjffACXTJowlJU+25Uj0cTp7EcXmueW0tFzx5XtBpEkUn/7tKlAp8qmJw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEJ2c5EKolI/Ufy8z4WbRHszp9y+SrApCDWV3ZZuUVUXAiAiL8lID0ZKwpBjCyOe8qD+kmD1FWoag2NwbWFE/6vWLg=="}],"size":1971,"noattachment":false,"key":"/write-pkg/-/write-pkg-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/write-pkg-3.0.0.tgz_1492410311067_0.6549546655733138"},"directories":{},"readme":"# write-pkg\n\n> Write a `package.json` file\n\nWrites atomically and creates directories for you as needed. Sorts dependencies when writing. Preserves the indentation if the file already exists.\n\n## Install\n\n```sh\nnpm install write-pkg\n```\n\n## Usage\n\n```js\nimport path from 'node:path';\nimport {writePackage} from 'write-pkg';\n\nawait writePackage({foo: true});\nconsole.log('done');\n\nawait writePackage(path.join('unicorn', 'package.json'), {foo: true});\nconsole.log('done');\n```\n\n## API\n\n### writePackage(path?, data, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written.\n\n### writePackageSync(path?, data, options?)\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### data\n\nType `object`\n\nJSON data to write to the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### updatePackage(path?, data, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been updated.\n\n### updatePackageSync(path?, data, options?)\n\n```js\nimport {updatePackage} from 'write-pkg';\n\nawait updatePackage({foo: true});\n//=> { \"foo\": true }\n\nawait updatePackage({foo: false, bar: true});\n//=> { \"foo\": false, \"bar\": true }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### data\n\nType `object`\n\nJSON data to write to the `package.json` file. If the file already exists, existing fields will be merged with the values in `data`.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### addPackageDependencies(path?, dependencies, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written.\n\n### addPackageDependenciesSync(path?, dependencies, options?)\n\n```js\nimport {writePackage, addPackageDependencies} from 'write-pkg';\n\nawait writePackage({foo: true});\n//=> { \"foo\": true }\n\nawait addPackageDependencies({foo: '1.0.0'});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" } }\n\nawait addPackageDependencies({dependencies: {foo: '1.0.0'}, devDependencies: {bar: '1.0.0'}});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" }, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### dependencies\n\nType: `Record<string, string> | Partial<Record<'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies', Record<string, string>>>`\n\nDependencies to add to the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### removePackageDependencies(path?, dependencies, options?)\n\nReturns a `Promise` that resolves when the `package.json` file has been written. Does not throw if the file does not exist.\n\n### removePackageDependenciesSync(path?, dependencies, options?)\n\n```js\nimport {writePackage, removePackageDependencies} from 'write-pkg';\n\nawait writePackage({foo: true, dependencies: {foo: '1.0.0'}, devDependencies: {bar: '1.0.0'}});\n//=> { \"foo\": true, \"dependencies\": { \"foo\": \"1.0.0\" }, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n\nawait removePackageDependencies(['foo']);\n//=> { \"foo\": true, \"devDependencies\": { \"bar\": \"1.0.0\" } }\n\nawait removePackageDependencies({devDependencies: ['bar']});\n//=> { \"foo\": true }\n```\n\n#### path\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe path to where the `package.json` file should be written or its directory.\n\n#### dependencies\n\nType `string[] | Partial<Record<'dependencies' | 'devDependencies' | 'optionalDependencies' | 'peerDependencies', string[]>>`\n\nDependencies to remove from the `package.json` file.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-4).\n\n### Options\n\n##### indent\n\nType: `string | number`\\\nDefault: Auto-detected or `'\\t'`\n\nThe indentation to use for new files.\n\nAccepts `'\\t'` for tab indentation or a number of spaces.\n\nIf the file already exists, the existing indentation will be used.\n\n##### normalize\n\nType: `boolean`\\\nDefault: `true`\n\nRemove empty `dependencies`, `devDependencies`, `optionalDependencies` and `peerDependencies` objects.\n\n## write-pkg for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of write-pkg and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-write-pkg?utm_source=npm-write-pkg&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)\n\n## Related\n\n- [read-pkg](https://github.com/sindresorhus/read-pkg) - Read a `package.json` file\n- [write-json-file](https://github.com/sindresorhus/write-json-file) - Stringify and write JSON to a file atomically\n\n","publish_time":1492410311376,"_cnpm_publish_time":1492410311376,"dist-tags":{"latest":"7.0.0"}}