Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: npm/normalize-package-data
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.0.0
Choose a base ref
...
head repository: npm/normalize-package-data
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v4.0.1
Choose a head ref
  • 8 commits
  • 18 files changed
  • 5 contributors

Commits on Mar 28, 2022

  1. chore: bump @npmcli/template-oss from 2.9.2 to 3.2.0 (#139)

    * chore: bump @npmcli/template-oss from 2.9.2 to 3.2.0
    
    Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 2.9.2 to 3.2.0.
    - [Release notes](https://github.com/npm/template-oss/releases)
    - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md)
    - [Commits](npm/template-oss@v2.9.2...v3.2.0)
    
    ---
    updated-dependencies:
    - dependency-name: "@npmcli/template-oss"
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * chore: postinstall for dependabot template-oss PR
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Gar <gar+gh@danger.computer>
    dependabot[bot] and wraithgar authored Mar 28, 2022

    Partially verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
    Copy the full SHA
    c46cd83 View commit details
  2. chore: bump tap from 15.2.3 to 16.0.1 (#140)

    Bumps [tap](https://github.com/tapjs/node-tap) from 15.2.3 to 16.0.1.
    - [Release notes](https://github.com/tapjs/node-tap/releases)
    - [Commits](tapjs/tapjs@v15.2.3...v16.0.1)
    
    ---
    updated-dependencies:
    - dependency-name: tap
      dependency-type: direct:development
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 28, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    374f9da View commit details

Commits on Apr 20, 2022

  1. chore: bump @npmcli/template-oss from 3.2.0 to 3.4.1 (#143)

    * chore: bump @npmcli/template-oss from 3.2.0 to 3.4.1
    
    Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.2.0 to 3.4.1.
    - [Release notes](https://github.com/npm/template-oss/releases)
    - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md)
    - [Commits](npm/template-oss@v3.2.0...v3.4.1)
    
    ---
    updated-dependencies:
    - dependency-name: "@npmcli/template-oss"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * chore: postinstall for dependabot template-oss PR
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Luke Karrys <luke@lukekarrys.com>
    dependabot[bot] and lukekarrys authored Apr 20, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6f87c24 View commit details

Commits on Apr 30, 2022

  1. chore: bump @npmcli/template-oss from 3.4.1 to 3.4.2

    Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.4.1 to 3.4.2.
    - [Release notes](https://github.com/npm/template-oss/releases)
    - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md)
    - [Commits](npm/template-oss@v3.4.1...v3.4.2)
    
    ---
    updated-dependencies:
    - dependency-name: "@npmcli/template-oss"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and lukekarrys committed Apr 30, 2022
    Copy the full SHA
    4225734 View commit details
  2. Copy the full SHA
    4b4dd60 View commit details

Commits on Jun 29, 2022

  1. chore: bump @npmcli/template-oss from 3.4.2 to 3.4.3 (#145)

    * chore: bump @npmcli/template-oss from 3.4.2 to 3.4.3
    
    Bumps [@npmcli/template-oss](https://github.com/npm/template-oss) from 3.4.2 to 3.4.3.
    - [Release notes](https://github.com/npm/template-oss/releases)
    - [Changelog](https://github.com/npm/template-oss/blob/main/CHANGELOG.md)
    - [Commits](npm/template-oss@v3.4.2...v3.4.3)
    
    ---
    updated-dependencies:
    - dependency-name: "@npmcli/template-oss"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    * chore: postinstall for dependabot template-oss PR
    
    * chore: postinstall for dependabot template-oss PR
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: npm team <ops+robot@npmjs.com>
    Co-authored-by: Luke Karrys <luke@lukekarrys.com>
    3 people authored Jun 29, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    76b56ef View commit details

Commits on Aug 15, 2022

  1. fix: linting (#146)

    wraithgar authored Aug 15, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    850038e View commit details
  2. chore(main): release 4.0.1 (#147)

    Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    github-actions[bot] authored Aug 15, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    33d8842 View commit details
5 changes: 2 additions & 3 deletions .commitlintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// This file is automatically added by @npmcli/template-oss. Do not edit.
/* This file is automatically added by @npmcli/template-oss. Do not edit. */

module.exports = {
extends: ['@commitlint/config-conventional'],
// If you change rules be sure to also update release-please.yml
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'chore', 'deps']],
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// This file is automatically added by @npmcli/template-oss. Do not edit.
/* This file is automatically added by @npmcli/template-oss. Do not edit. */

'use strict'

const { readdirSync: readdir } = require('fs')

@@ -7,6 +9,7 @@ const localConfigs = readdir(__dirname)
.map((file) => `./${file}`)

module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
4 changes: 3 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* @npm/cli-team
# This file is automatically added by @npmcli/template-oss. Do not edit.

* @npm/cli-team
88 changes: 44 additions & 44 deletions .github/ISSUE_TEMPLATE/bug.yml
Original file line number Diff line number Diff line change
@@ -3,52 +3,52 @@
name: Bug
description: File a bug/issue
title: "[BUG] <title>"
labels: [Bug, Needs Triage]
labels: [ Bug, Needs Triage ]

body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false

validations:
required: false
25 changes: 13 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

version: 2

updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
allow:
- dependency-type: direct
versioning-strategy: increase
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
22 changes: 13 additions & 9 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
@@ -3,21 +3,25 @@
name: Audit

on:
workflow_dispatch:
schedule:
# "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1
- cron: "0 1 * * 1"
workflow_dispatch:

jobs:
audit:
name: npm audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install deps
run: npm i --package-lock
- name: Audit
run: npm audit
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- run: npm audit
60 changes: 42 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -3,7 +3,10 @@
name: CI

on:
workflow_dispatch:
pull_request:
branches:
- '*'
push:
branches:
- main
@@ -16,47 +19,68 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: '16'
- run: npm i --prefer-online -g npm@latest
- run: npm i
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm run lint

test:
strategy:
fail-fast: false
matrix:
node-version: [12.13.0, 12.x, 14.15.0, 14.x, 16.13.0, 16.x]
node-version:
- 12.13.0
- 12.x
- 14.15.0
- 14.x
- 16.0.0
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update to workable npm (windows)
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12') || startsWith(matrix.node-version, '14'))
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Update npm
- name: Update npm to 7
# If we do test on npm 10 it needs npm7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Update npm to latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm test --ignore-scripts
30 changes: 18 additions & 12 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -4,10 +4,14 @@ name: "CodeQL"

on:
push:
branches: [ main ]
branches:
- main
- latest
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches:
- main
- latest
schedule:
# "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
- cron: "0 3 * * 1"
@@ -24,15 +28,17 @@ jobs:
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: [ javascript ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
30 changes: 19 additions & 11 deletions .github/workflows/post-dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
# This file is automatically added by @npmcli/template-oss. Do not edit.

name: "Post Dependabot Actions"
name: Post Dependabot Actions

on: pull_request

# https://docs.github.com/en/rest/overview/permissions-required-for-github-apps
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: write

jobs:
Install:
template-oss-apply:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: npm install and commit
if: ${{contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')}}
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --local user.email "ops+npm-cli@npmjs.com"
git config --local user.name "npm cli ops bot"
gh pr checkout ${{ github.event.pull_request.number }}
npm install
npm install --ignore-scripts --no-audit --no-fund
npm run template-oss-apply
git add .
git commit -am "chore: postinstall for dependabot template-oss PR"
git push
npm run lint
25 changes: 18 additions & 7 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -4,24 +4,35 @@ name: Pull Request Linting

on:
pull_request:
types: [opened, reopened, edited, synchronize]
types:
- opened
- reopened
- edited
- synchronize

jobs:
check:
name: Check PR Title or Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v2
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: '16'
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Install deps
run: |
npm i -D @commitlint/cli @commitlint/config-conventional
run: npm i -D @commitlint/cli @commitlint/config-conventional
- name: Check commits OR PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
npx commitlint -x @commitlint/config-conventional -V --from origin/main --to ${{ github.event.pull_request.head.sha }} || echo $PR_TITLE | npx commitlint -x @commitlint/config-conventional -V
npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \
|| echo $PR_TITLE | npx --offline commitlint -V
16 changes: 9 additions & 7 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -6,19 +6,21 @@ on:
push:
branches:
- main
- latest

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v2
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
# If you change changelog-types be sure to also update commitlintrc.js
changelog-types: >
[{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}]
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}
]
27 changes: 15 additions & 12 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,20 +4,23 @@
/*

# keep these
!/.commitlintrc.js
!/.npmrc
!/.eslintrc*
!/.github
!/.eslintrc.local.*
!**/.gitignore
!/package.json
!/docs
!/bin
!/lib
!/docs/
!/tap-snapshots/
!/test/
!/map.js
!/tap-snapshots
!/test
!/scripts
!/scripts/
!/README*
!/LICENSE*
!/SECURITY*
!/CHANGELOG*
!/.commitlintrc.js
!/.eslintrc.js
!/.github/
!/.gitignore
!/.npmrc
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/lib/
!/package.json
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
;This file is automatically added by @npmcli/template-oss. Do not edit.
; This file is automatically added by @npmcli/template-oss. Do not edit.

package-lock=false
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [4.0.1](https://github.com/npm/normalize-package-data/compare/v4.0.0...v4.0.1) (2022-08-15)


### Bug Fixes

* linting ([#146](https://github.com/npm/normalize-package-data/issues/146)) ([850038e](https://github.com/npm/normalize-package-data/commit/850038e68baa8155f55f9169977cb631fecbe1d4))

## [4.0.0](https://www.github.com/npm/normalize-package-data/compare/v3.0.3...v4.0.0) (2022-03-14)


7 changes: 7 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!-- This file is automatically added by @npmcli/template-oss. Do not edit. -->

All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)

The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
12 changes: 7 additions & 5 deletions lib/extract_description.js
Original file line number Diff line number Diff line change
@@ -11,12 +11,14 @@ function extractDescription (d) {
// the first block of text before the first heading
// that isn't the first line heading
d = d.trim().split('\n')
for (var s = 0; d[s] && d[s].trim().match(/^(#|$)/); s++) {
;
let s = 0
while (d[s] && d[s].trim().match(/^(#|$)/)) {
s++
}
var l = d.length
for (var e = s + 1; e < l && d[e].trim(); e++) {
;
const l = d.length
let e = s + 1
while (e < l && d[e].trim()) {
e++
}
return d.slice(s, e).join(' ').trim()
}
36 changes: 18 additions & 18 deletions lib/fixer.js
Original file line number Diff line number Diff line change
@@ -121,17 +121,17 @@ module.exports = {
this.warn('nonArrayBundleDependencies')
delete data[bd]
} else if (data[bd]) {
data[bd] = data[bd].filter(function (bd) {
if (!bd || typeof bd !== 'string') {
this.warn('nonStringBundleDependency', bd)
data[bd] = data[bd].filter(function (filtered) {
if (!filtered || typeof filtered !== 'string') {
this.warn('nonStringBundleDependency', filtered)
return false
} else {
if (!data.dependencies) {
data.dependencies = {}
}
if (!Object.prototype.hasOwnProperty.call(data.dependencies, bd)) {
this.warn('nonDependencyBundleDependency', bd)
data.dependencies[bd] = '*'
if (!Object.prototype.hasOwnProperty.call(data.dependencies, filtered)) {
this.warn('nonDependencyBundleDependency', filtered)
data.dependencies[filtered] = '*'
}
return true
}
@@ -389,28 +389,28 @@ function unParsePerson (person) {
}
var name = person.name || ''
var u = person.url || person.web
var url = u ? (' (' + u + ')') : ''
var wrappedUrl = u ? (' (' + u + ')') : ''
var e = person.email || person.mail
var email = e ? (' <' + e + '>') : ''
return name + email + url
var wrappedEmail = e ? (' <' + e + '>') : ''
return name + wrappedEmail + wrappedUrl
}

function parsePerson (person) {
if (typeof person !== 'string') {
return person
}
var name = person.match(/^([^(<]+)/)
var url = person.match(/\(([^()]+)\)/)
var email = person.match(/<([^<>]+)>/)
var matchedName = person.match(/^([^(<]+)/)
var matchedUrl = person.match(/\(([^()]+)\)/)
var matchedEmail = person.match(/<([^<>]+)>/)
var obj = {}
if (name && name[0].trim()) {
obj.name = name[0].trim()
if (matchedName && matchedName[0].trim()) {
obj.name = matchedName[0].trim()
}
if (email) {
obj.email = email[1]
if (matchedEmail) {
obj.email = matchedEmail[1]
}
if (url) {
obj.url = url[1]
if (matchedUrl) {
obj.url = matchedUrl[1]
}
return obj
}
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "normalize-package-data",
"version": "4.0.0",
"version": "4.0.1",
"author": "GitHub Inc.",
"description": "Normalizes data that can be found in package.json files.",
"license": "BSD-2-Clause",
"repository": {
"type": "git",
"url": "git://github.com/npm/normalize-package-data.git"
"url": "https://github.com/npm/normalize-package-data.git"
},
"main": "lib/normalize.js",
"scripts": {
@@ -15,13 +15,13 @@
"preversion": "npm test",
"test": "tap",
"npmclilint": "npmcli-lint",
"lint": "eslint '**/*.js'",
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
"postlint": "npm-template-check",
"template-copy": "npm-template-copy --force",
"snap": "tap"
"postlint": "template-oss-check",
"snap": "tap",
"template-oss-apply": "template-oss-apply --force"
},
"dependencies": {
"hosted-git-info": "^5.0.0",
@@ -30,18 +30,20 @@
"validate-npm-package-license": "^3.0.4"
},
"devDependencies": {
"@npmcli/template-oss": "^2.9.2",
"tap": "^15.0.9"
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.5.0",
"tap": "^16.0.1"
},
"files": [
"bin",
"lib"
"bin/",
"lib/"
],
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16"
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"templateOSS": {
"version": "2.9.2"
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.5.0"
},
"tap": {
"branches": 86,