(data)
| 94 | } |
| 95 | |
| 96 | write (data) { |
| 97 | if (!filter(data, this.#exclude)) { |
| 98 | return |
| 99 | } |
| 100 | // Normalize |
| 101 | const pkg = { |
| 102 | authors: data.maintainers.map((m) => `${strip(m.username)}`).join(' '), |
| 103 | publisher: strip(data.publisher?.username || ''), |
| 104 | date: data.date ? data.date.toISOString().slice(0, 10) : 'prehistoric', |
| 105 | description: strip(data.description ?? ''), |
| 106 | keywords: [], |
| 107 | name: strip(data.name), |
| 108 | version: data.version, |
| 109 | } |
| 110 | if (Array.isArray(data.keywords)) { |
| 111 | pkg.keywords = data.keywords.map(strip) |
| 112 | } else if (typeof data.keywords === 'string') { |
| 113 | pkg.keywords = strip(data.keywords.replace(/[,\s]+/, ' ')).split(' ') |
| 114 | } |
| 115 | |
| 116 | let output |
| 117 | if (this.#parseable) { |
| 118 | output = [pkg.name, pkg.description, pkg.author, pkg.date, pkg.version, pkg.keywords] |
| 119 | .filter(Boolean) |
| 120 | .map(col => ('' + col).replace(/\t/g, ' ')).join('\t') |
| 121 | return super.write(output) |
| 122 | } |
| 123 | |
| 124 | const keywords = pkg.keywords.map(k => { |
| 125 | if (this.#args.includes(k)) { |
| 126 | return this.#chalk.cyan(k) |
| 127 | } else { |
| 128 | return k |
| 129 | } |
| 130 | }).join(' ') |
| 131 | |
| 132 | const description = this.#highlight(pkg.description) |
| 133 | let name |
| 134 | if (this.#args.includes(pkg.name)) { |
| 135 | name = this.#chalk.cyan(pkg.name) |
| 136 | } else { |
| 137 | name = this.#highlight(pkg.name) |
| 138 | name = this.#chalk.blue(name) |
| 139 | } |
| 140 | |
| 141 | if (description.length) { |
| 142 | output = `${name}\n${description}\n` |
| 143 | } else { |
| 144 | output = `${name}\n` |
| 145 | } |
| 146 | if (pkg.publisher) { |
| 147 | output += `Version ${this.#chalk.blue(pkg.version)} published ${this.#chalk.blue(pkg.date)} by ${this.#chalk.blue(pkg.publisher)}\n` |
| 148 | } else { |
| 149 | output += `Version ${this.#chalk.blue(pkg.version)} published ${this.#chalk.blue(pkg.date)} by ${this.#chalk.yellow('???')}\n` |
| 150 | } |
| 151 | output += `Maintainers: ${pkg.authors}\n` |
| 152 | if (keywords) { |
| 153 | output += `Keywords: ${keywords}\n` |
nothing calls this directly
no test coverage detected