Comparing version 0.2.10 to 0.2.11
{ | ||
"name": "publint", | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"description": "Lint packaging errors", | ||
@@ -47,3 +47,3 @@ "type": "module", | ||
"npm-packlist": "^5.1.3", | ||
"picocolors": "^1.0.1", | ||
"picocolors": "^1.1.0", | ||
"sade": "^1.8.1" | ||
@@ -50,0 +50,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
import c from 'picocolors' | ||
import picocolors from 'picocolors' | ||
import { | ||
@@ -8,7 +8,21 @@ formatMessagePath as fp, | ||
/** @type { import('picocolors/types.js').Colors | undefined } */ | ||
let _picocolorsHasColors | ||
/** @type { import('picocolors/types.js').Colors | undefined } */ | ||
let _picocolorsNoColors | ||
/** | ||
* @param {import('../index.d.ts').Message} m | ||
* @param {import('./utils.js').Pkg} pkg | ||
* @param {import('../utils.d.ts').FormatMessageOptions} opts | ||
*/ | ||
export function formatMessage(m, pkg) { | ||
export function formatMessage(m, pkg, opts = {}) { | ||
/** @type { import('picocolors/types.js').Colors } */ | ||
let c = picocolors | ||
if (opts.color === true) { | ||
c = _picocolorsHasColors ??= picocolors.createColors(true) | ||
} else if (opts.color === false) { | ||
c = _picocolorsNoColors ??= picocolors.createColors(false) | ||
} | ||
/** @param {string[]} path */ | ||
@@ -15,0 +29,0 @@ const pv = (path) => getPkgPathValue(pkg, path) |
@@ -5,2 +5,12 @@ import type { Message } from './index.js' | ||
export interface FormatMessageOptions { | ||
/** | ||
* Whether the returned string should contain color. | ||
* - `true`: Force has color. | ||
* - `false`: Force no color. | ||
* - `undefined`: Default to whether the environment supports color. | ||
*/ | ||
color?: boolean | undefined | ||
} | ||
export declare function formatMessagePath(path: string[]): string | ||
@@ -10,3 +20,4 @@ export declare function getPkgPathValue(pkg: Pkg, path: string[]): any | ||
msg: Message, | ||
pkg: Pkg | ||
pkg: Pkg, | ||
opts?: FormatMessageOptions | ||
): string | undefined |
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
79620
2086
Updatedpicocolors@^1.1.0