Socket
Socket
Sign inDemoInstall

write-json-file

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

write-json-file - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

23

index.js
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var writeFileAtomic = require('write-file-atomic');
var sortKeys = require('sort-keys');
var objectAssign = require('object-assign');
var mkdirp = require('mkdirp');
var Promise = require('pinkie-promise');

@@ -9,2 +12,10 @@ var pify = require('pify');

function main(fn, fp, data, opts) {
if (!fp) {
throw new TypeError('Expected a filepath');
}
if (data === undefined) {
throw new TypeError('Expected data to stringify');
}
opts = objectAssign({

@@ -27,3 +38,11 @@ indent: '\t',

module.exports = main.bind(null, pify(writeFileAtomic, Promise));
module.exports.sync = main.bind(null, writeFileAtomic.sync);
module.exports = function (fp, data, opts) {
return pify(mkdirp, Promise)(path.dirname(fp), {fs: fs}).then(function () {
return main(pify(writeFileAtomic, Promise), fp, data, opts);
});
};
module.exports.sync = function (fp, data, opts) {
mkdirp.sync(path.dirname(fp), {fs: fs});
main(writeFileAtomic.sync, fp, data, opts);
};

4

package.json
{
"name": "write-json-file",
"version": "1.0.0",
"version": "1.1.0",
"description": "Stringify and write JSON to a file atomically",

@@ -36,2 +36,4 @@ "license": "MIT",

"dependencies": {
"graceful-fs": "^4.1.2",
"mkdirp": "^0.5.1",
"object-assign": "^4.0.1",

@@ -38,0 +40,0 @@ "pify": "^1.1.0",

@@ -5,3 +5,5 @@ # write-json-file [![Build Status](https://travis-ci.org/sindresorhus/write-json-file.svg?branch=master)](https://travis-ci.org/sindresorhus/write-json-file)

Creates directories for you as needed.
## Install

@@ -8,0 +10,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc