Socket
Socket
Sign inDemoInstall

@npmcli/package-json

Package Overview
Dependencies
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@npmcli/package-json - npm Package Compare versions

Comparing version 5.1.1 to 5.2.0

lib/read-package.js

19

lib/index.js

@@ -1,3 +0,5 @@

const { readFile, writeFile } = require('fs/promises')
const { resolve } = require('path')
const { readFile, writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')
const parseJSON = require('json-parse-even-better-errors')
const updateDeps = require('./update-dependencies.js')

@@ -7,5 +9,4 @@ const updateScripts = require('./update-scripts.js')

const normalize = require('./normalize.js')
const { read, parse } = require('./read-package.js')
const parseJSON = require('json-parse-even-better-errors')
// a list of handy specialized helper functions that take

@@ -130,5 +131,4 @@ // care of special cases that are handled by the npm cli

try {
this.#readFileContent = await readFile(this.filename, 'utf8')
this.#readFileContent = await read(this.filename)
} catch (err) {
err.message = `Could not read package.json: ${err}`
if (!parseIndex) {

@@ -163,8 +163,3 @@ throw err

fromJSON (data) {
try {
this.#manifest = parseJSON(data)
} catch (err) {
err.message = `Invalid package.json: ${err}`
throw err
}
this.#manifest = parse(data)
return this

@@ -171,0 +166,0 @@ }

const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const path = require('path')
const fs = require('node:fs/promises')
const path = require('node:path')
const { log } = require('proc-log')

@@ -6,0 +6,0 @@

{
"name": "@npmcli/package-json",
"version": "5.1.1",
"version": "5.2.0",
"description": "Programmatic API to update package.json",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -53,2 +53,11 @@ # @npmcli/package-json

There is also a helper function exported for opening a package.json file
with no extra normalization or saving functionality.
```js
const { readPackage } = require('@npmcli/package-json/lib/read-package')
const rawData = await readPackage('./package.json')
// rawData will now have the package.json contents with no changes or normalizations
```
## API:

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