write-json-file
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ 'use strict'; | ||
const sortKeys = require('sort-keys'); | ||
const mkdirp = require('mkdirp'); | ||
const makeDir = require('make-dir'); | ||
const pify = require('pify'); | ||
@@ -37,8 +37,8 @@ | ||
module.exports = (fp, data, opts) => | ||
pify(mkdirp)(path.dirname(fp), {fs}) | ||
makeDir(path.dirname(fp), {fs}) | ||
.then(() => main(pify(writeFileAtomic), fp, data, opts)); | ||
module.exports.sync = (fp, data, opts) => { | ||
mkdirp.sync(path.dirname(fp), {fs}); | ||
makeDir.sync(path.dirname(fp), {fs}); | ||
main(writeFileAtomic.sync, fp, data, opts); | ||
}; |
{ | ||
"name": "write-json-file", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Stringify and write JSON to a file atomically", | ||
@@ -37,15 +37,12 @@ "license": "MIT", | ||
"graceful-fs": "^4.1.2", | ||
"mkdirp": "^0.5.1", | ||
"make-dir": "^1.0.0", | ||
"pify": "^2.0.0", | ||
"sort-keys": "^1.1.1", | ||
"write-file-atomic": "^1.1.2" | ||
"write-file-atomic": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"tempfile": "^1.1.1", | ||
"tempfile": "^2.0.0", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
} |
# write-json-file [](https://travis-ci.org/sindresorhus/write-json-file) | ||
> Stringify and write JSON to a file [atomically](https://github.com/iarna/write-file-atomic) | ||
> Stringify and write JSON to a file [atomically](https://github.com/npm/write-file-atomic) | ||
@@ -30,3 +30,3 @@ Creates directories for you as needed. | ||
Returns a promise. | ||
Returns a `Promise`. | ||
@@ -37,8 +37,10 @@ ### writeJsonFile.sync(filepath, data, [options]) | ||
Type: `Object` | ||
##### indent | ||
Type: `string`, `number` | ||
Type: `string` `number`<br> | ||
Default: `\t` | ||
Indentation as a string or number of spaces. | ||
Indentation as a string or number of spaces.<br> | ||
Pass in `null` for no formatting. | ||
@@ -48,6 +50,6 @@ | ||
Type: `boolean`, `function` | ||
Type: `boolean` `function`<br> | ||
Default: `false` | ||
Sort the keys recursively. | ||
Sort the keys recursively.<br> | ||
Optionally pass in a [`compare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) function. | ||
@@ -63,4 +65,4 @@ | ||
Type: `number` | ||
Default `438` *(0666 in octal)* | ||
Type: `number`<br> | ||
Default: `0o666` | ||
@@ -73,2 +75,3 @@ [Mode](https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation) used when writing the file. | ||
- [load-json-file](https://github.com/sindresorhus/load-json-file) - Read and parse a JSON file | ||
- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed | ||
@@ -78,2 +81,2 @@ | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
4635
1.69%77
4.05%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated