@npmcli/package-json
Advanced tools
Comparing version 5.1.1 to 5.2.0
@@ -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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39533
9
958
244
1