/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v6.5.0
scripts/utils.mjs
40 строк
1 KB
Diego Andai
[material-ui][mui-system] Simplify version prerelease export (#43699)
11 сен 2024, 15:20
Не верифицирован
11 сен 2024, 15:20
494c10c
Код
Авторство
О чём код?
import path from 'path'; import url from 'url'; import fs from 'fs/promises'; /** * Returns the full path of the root directory of this repository. */ // eslint-disable-next-line import/prefer-default-export export function getWorkspaceRoot() { const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); const workspaceRoot = path.resolve(currentDirectory, '..'); return workspaceRoot; } /** * Returns the version and destructured values of the version as env variables to be replaced. */ export async function getVersionEnvVariables() { const packageJsonData = await fs.readFile(path.resolve('./package.json'), 'utf8'); const { version = null } = JSON.parse(packageJsonData); if (!version) { throw new Error('Could not find the version in the package.json'); } const [versionNumber, prerelease] = version.split('-'); const [major, minor, patch] = versionNumber.split('.'); if (!major || !minor || !patch) { throw new Error(`Couldn't parse version from package.json`); } return { MUI_VERSION: version, MUI_MAJOR_VERSION: major, MUI_MINOR_VERSION: minor, MUI_PATCH_VERSION: patch, MUI_PRERELEASE: prerelease, }; }