/
githubmirror
/
tailwindcss
Обзор
Документация
Войти
/
githubmirror
/
tailwindcss
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/@tailwindcss-upgrade/src/utils/package-version.ts
29 строк
844 B
Robin Malfait
Ensure `@tailwindcss/upgrade` runs on Tailwind CSS v4 projects and is idempotent (#17717)
22 апр 2025, 18:10
Не верифицирован
22 апр 2025, 18:10
8e826b1
Код
Авторство
О чём код?
import { readFileSync } from 'node:fs' import fs from 'node:fs/promises' import { resolveJsId } from './resolve' /** * Resolves the version string of an npm dependency installed in the based * directory. */ export async function getPackageVersion(pkg: string, base: string): Promise<string | null> { try { let packageJson = resolveJsId(`${pkg}/package.json`, base) if (!packageJson) return null let { version } = JSON.parse(await fs.readFile(packageJson, 'utf8')) return version } catch { return null } } export function getPackageVersionSync(pkg: string, base: string): string | null { try { let packageJson = resolveJsId(`${pkg}/package.json`, base) if (!packageJson) return null let { version } = JSON.parse(readFileSync(packageJson, 'utf8')) return version } catch { return null } }