UNPKG

@openscript/unplugin-favicons

Version:

Generate favicons for your project with caching for blazing fast rebuilds.

68 lines 2.19 kB
import { findPackageJsonSync } from "@visulima/package"; import parseAuthor from "parse-author"; export default class Oracle { packageJson; constructor(startingPath) { try { const readPackage = findPackageJsonSync(startingPath); this.packageJson = readPackage?.packageJson; } catch { /* empty */ } } /** * Tries to guess the name from package.json */ guessAppName() { return this.packageJson?.name; } /** * Tries to guess the description from package.json */ guessDescription() { return this.packageJson?.description; } /** * Tries to guess the developer {name, email, url} from package.json */ guessDeveloper() { if (this.packageJson?.author !== undefined) { if (typeof this.packageJson.author === "string") { return parseAuthor(this.packageJson.author); } if (typeof this.packageJson.author === "object" && this.packageJson.author !== null) { return { email: this.packageJson.author?.email, name: this.packageJson.author.name, url: this.packageJson.author?.url, }; } } if (this.packageJson?.maintainers !== undefined && Array.isArray(this.packageJson.maintainers) && this.packageJson.maintainers.length > 0) { const maintainer = this.packageJson.maintainers[0]; if (typeof maintainer === "string") { return parseAuthor(maintainer); } if (typeof maintainer === "object" && maintainer !== null) { return { email: maintainer?.email, name: maintainer.name, url: maintainer?.url, }; } } return { email: undefined, name: undefined, url: undefined, }; } /** * Tries to guess the version from package.json */ guessVersion() { return this.packageJson?.version; } } //# sourceMappingURL=oracle.js.map