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.0.1 to 5.0.2

40

lib/normalize.js
const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const { glob } = require('glob')
const path = require('path')
const log = require('proc-log')
const hostedGitInfo = require('hosted-git-info')
/**
* @type {import('hosted-git-info')}
*/
let _hostedGitInfo
function lazyHostedGitInfo () {
if (!_hostedGitInfo) {
_hostedGitInfo = require('hosted-git-info')
}
return _hostedGitInfo
}
/**
* @type {import('glob').glob}
*/
let _glob
function lazyLoadGlob () {
if (!_glob) {
_glob = require('glob').glob
}
return _glob
}
// used to be npm-normalize-package-bin

@@ -209,3 +229,3 @@ function normalizePackageBin (pkg, changes) {

if (!scripts.install && !scripts.preinstall && data.gypfile !== false) {
const files = await glob('*.gyp', { cwd: pkg.path })
const files = await lazyLoadGlob()('*.gyp', { cwd: pkg.path })
if (files.length) {

@@ -277,3 +297,7 @@ scripts.install = 'node-gyp rebuild'

const mdre = /\.m?a?r?k?d?o?w?n?$/i
const files = await glob('{README,README.*}', { cwd: pkg.path, nocase: true, mark: true })
const files = await lazyLoadGlob()('{README,README.*}', {
cwd: pkg.path,
nocase: true,
mark: true,
})
let readmeFile

@@ -309,3 +333,3 @@ for (const file of files) {

const cwd = path.resolve(pkg.path, manDir)
const files = await glob('**/*.[0-9]', { cwd })
const files = await lazyLoadGlob()('**/*.[0-9]', { cwd })
data.man = files.map(man =>

@@ -323,3 +347,3 @@ path.relative(pkg.path, path.join(cwd, man)).split(path.sep).join('/')

const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
const bins = await glob('**', { cwd: binsDir })
const bins = await lazyLoadGlob()('**', { cwd: binsDir })
data.bin = bins.reduce((acc, binFile) => {

@@ -452,3 +476,3 @@ if (binFile && !binFile.startsWith('.')) {

if (data.repository.url) {
const hosted = hostedGitInfo.fromUrl(data.repository.url)
const hosted = lazyHostedGitInfo().fromUrl(data.repository.url)
let r

@@ -513,3 +537,3 @@ if (hosted) {

}
const hosted = hostedGitInfo.fromUrl(data[deps][d])?.toString()
const hosted = lazyHostedGitInfo().fromUrl(data[deps][d])?.toString()
if (hosted && hosted !== data[deps][d]) {

@@ -516,0 +540,0 @@ changes?.push(`Normalized git reference to "${deps}.${d}"`)

2

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

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

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