Socket
Socket
Sign inDemoInstall

write-json-file

Package Overview
Dependencies
11
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.1 to 4.3.0

10

index.js

@@ -13,4 +13,2 @@ 'use strict';

const hasTrailingNewline = file => /\n$/.test(file);
const init = (fn, filePath, data, options) => {

@@ -46,3 +44,3 @@ if (!filePath) {

const file = await readFile(filePath, 'utf8');
if (!hasTrailingNewline(file)) {
if (!file.endsWith('\n')) {
trailingNewline = '';

@@ -62,3 +60,3 @@ }

return writeFileAtomic(filePath, `${json}${trailingNewline}`, {mode: options.mode});
return writeFileAtomic(filePath, `${json}${trailingNewline}`, {mode: options.mode, chown: false});
};

@@ -71,3 +69,3 @@

const file = fs.readFileSync(filePath, 'utf8');
if (!hasTrailingNewline(file)) {
if (!file.endsWith('\n')) {
trailingNewline = '';

@@ -87,3 +85,3 @@ }

return writeFileAtomic.sync(filePath, `${json}${trailingNewline}`, {mode: options.mode});
return writeFileAtomic.sync(filePath, `${json}${trailingNewline}`, {mode: options.mode, chown: false});
};

@@ -90,0 +88,0 @@

9

package.json
{
"name": "write-json-file",
"version": "4.2.1",
"version": "4.3.0",
"description": "Stringify and write JSON to a file atomically",
"license": "MIT",
"repository": "sindresorhus/write-json-file",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {

@@ -41,3 +42,3 @@ "name": "Sindre Sorhus",

"make-dir": "^3.0.0",
"sort-keys": "^3.0.0",
"sort-keys": "^4.0.0",
"write-file-atomic": "^3.0.0"

@@ -48,5 +49,5 @@ },

"tempy": "^0.3.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
"tsd": "^0.8.0",
"xo": "^0.25.3"
}
}

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

## Install

@@ -15,3 +14,2 @@

## Usage

@@ -27,3 +25,2 @@

## API

@@ -43,3 +40,3 @@

Type: `string | number`<br>
Type: `string | number`\
Default: `'\t'`

@@ -53,3 +50,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -61,6 +58,7 @@

Type: `boolean | Function`<br>
Type: `boolean | Function`\
Default: `false`
Sort the keys recursively.<br>
Sort the keys recursively.
Optionally pass in a [`compare`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) function.

@@ -76,3 +74,3 @@

Type: `number`<br>
Type: `number`\
Default: `0o666`

@@ -82,3 +80,2 @@

## write-json-file for enterprise

@@ -90,3 +87,2 @@

## Related

@@ -93,0 +89,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc