Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow searching packages with no description #6715

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/utils/format-search-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function highlightSearchTerms (str, terms) {
function normalizePackage (data, opts) {
return {
name: ansiTrim(data.name),
description: ansiTrim(data.description),
description: ansiTrim(data.description ?? ''),
author: data.maintainers.map((m) => `=${ansiTrim(m.username)}`).join(' '),
keywords: Array.isArray(data.keywords)
? data.keywords.map(ansiTrim).join(' ')
Expand Down
8 changes: 8 additions & 0 deletions tap-snapshots/test/lib/commands/search.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NAME | DESCRIPTION | AUTHOR | DATE
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
libnpmversion | library to do the… | =nlf… | 2020-11-04 | 1.0.7 |
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`

exports[`test/lib/commands/search.js TAP search <name> --color > should have expected search results with color 1`] = `
Expand All @@ -41,6 +42,7 @@ NAME | DESCRIPTION | AUTHOR | DATE
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
libnpmversion | library to do the… | =nlf… | 2020-11-04 | 1.0.7 | 
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 | 
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 | 
`

exports[`test/lib/commands/search.js TAP search <name> --parseable > should have expected search results as parseable 1`] = `
Expand All @@ -57,6 +59,7 @@ libnpmfund Programmatic API for npm fund =nlf =ruyadorno =darcyclarke =isaacs 20
@npmcli/map-workspaces Retrieves a name:pathname Map for a given workspaces config =nlf =ruyadorno =darcyclarke =isaacs 2020-09-30 1.0.1 npm npmcli libnpm cli workspaces map-workspaces
libnpmversion library to do the things that 'npm version' does =nlf =ruyadorno =darcyclarke =isaacs 2020-11-04 1.0.7
@types/libnpmsearch TypeScript definitions for libnpmsearch =types 2019-09-26 2.0.1
pkg-no-desc =lukekarrys 2019-09-26 1.0.0
`

exports[`test/lib/commands/search.js TAP search <name> > should have filtered expected search results 1`] = `
Expand All @@ -80,6 +83,7 @@ libnpmfund | Programmatic API… | =nlf… | 2020-12
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
libnpmversion | library to do the… | =nlf… | 2020-11-04 | 1.0.7 |
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`

exports[`test/lib/commands/search.js TAP search exclude forward slash > results should not have libnpmversion 1`] = `
Expand All @@ -96,6 +100,7 @@ libnpmpublish | Programmatic API… | =nlf… | 2020-11
libnpmfund | Programmatic API… | =nlf… | 2020-12-08 | 1.0.2 | npm npmcli libnpm cli git fund gitfund
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`

exports[`test/lib/commands/search.js TAP search exclude regex > results should not have libnpmversion 1`] = `
Expand All @@ -112,6 +117,7 @@ libnpmpublish | Programmatic API… | =nlf… | 2020-11
libnpmfund | Programmatic API… | =nlf… | 2020-12-08 | 1.0.2 | npm npmcli libnpm cli git fund gitfund
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`

exports[`test/lib/commands/search.js TAP search exclude string > results should not have libnpmversion 1`] = `
Expand All @@ -128,11 +134,13 @@ libnpmpublish | Programmatic API… | =nlf… | 2020-11
libnpmfund | Programmatic API… | =nlf… | 2020-12-08 | 1.0.2 | npm npmcli libnpm cli git fund gitfund
@npmcli/map-workspaces | Retrieves a… | =nlf… | 2020-09-30 | 1.0.1 | npm npmcli libnpm cli workspaces map-workspaces
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`

exports[`test/lib/commands/search.js TAP search exclude username with upper case letters > results should not have nlf 1`] = `
NAME | DESCRIPTION | AUTHOR | DATE | VERSION | KEYWORDS
@evocateur/libnpmaccess | programmatic… | =evocateur | 2019-07-16 | 3.1.2 |
@evocateur/libnpmpublish | Programmatic API… | =evocateur | 2019-07-16 | 1.2.2 |
@types/libnpmsearch | TypeScript… | =types | 2019-09-26 | 2.0.1 |
pkg-no-desc | | =lukekarrys | 2019-09-26 | 1.0.0 |
`
7 changes: 7 additions & 0 deletions test/fixtures/libnpmsearch-stream-result.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,11 @@ module.exports = [
publisher: { username: 'types', email: '[email protected]' },
maintainers: [{ username: 'types', email: '[email protected]' }],
},
{
name: 'pkg-no-desc',
scope: 'unscoped',
version: '1.0.0',
date: '2019-09-26T22:24:28.713Z',
maintainers: [{ username: 'lukekarrys', email: 'lukekarrys' }],
},
]
Loading