Socket
Socket
Sign inDemoInstall

write-pkg

Package Overview
Dependencies
10
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

22

index.js
'use strict';
const path = require('path');
const writeJsonFile = require('write-json-file');
const sortKeys = require('sort-keys');
const opts = {indent: 2};
const dependencyKeys = new Set([
'dependencies',
'devDependencies',
'optionalDependencies',
'peerDependencies'
]);
function normalize(pkg) {
const ret = {};
for (const key of Object.keys(pkg)) {
ret[key] = dependencyKeys.has(key) ? sortKeys(pkg[key]) : pkg[key];
}
return ret;
}
module.exports = (fp, data) => {

@@ -15,2 +33,4 @@ if (typeof fp !== 'string') {

data = normalize(data);
return writeJsonFile(fp, data, opts);

@@ -27,3 +47,5 @@ };

data = normalize(data);
writeJsonFile.sync(fp, data, opts);
};

6

package.json
{
"name": "write-pkg",
"version": "2.0.0",
"version": "2.1.0",
"description": "Write a package.json file",

@@ -32,2 +32,3 @@ "license": "MIT",

"dependencies": {
"sort-keys": "^1.1.2",
"write-json-file": "^2.0.0"

@@ -40,6 +41,3 @@ },

"xo": "*"
},
"xo": {
"esnext": true
}
}

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

Writes atomically and creates directories for you as needed.
Writes atomically and creates directories for you as needed. Sorts dependencies when writing.

@@ -8,0 +8,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