/
githubmirror
/
material-ui
Обзор
Документация
Войти
/
githubmirror
/
material-ui
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.18.0
scripts/copyFiles.mjs
70 строк
2 KB
Jan Potoms
[code-infra] Copy translations.json to @mui/docs build folder (#41472)
13 мар 2024, 17:32
Не верифицирован
13 мар 2024, 17:32
d26d07e
Код
Авторство
О чём код?
/* eslint-disable no-console */ import path from 'path'; import { createModulePackages, createPackageFile, includeFileInBuild, prepend, typescriptCopy, } from './copyFilesUtils.mjs'; const packagePath = process.cwd(); const buildPath = path.join(packagePath, './build'); const srcPath = path.join(packagePath, './src'); async function addLicense(packageData) { const license = `/** * ${packageData.name} v${packageData.version} * * @license ${packageData.license} * This source code is licensed under the ${packageData.license} license found in the * LICENSE file in the root directory of this source tree. */ `; await Promise.all( [ './index.js', './legacy/index.js', './modern/index.js', './node/index.js', './umd/material-ui.development.js', './umd/material-ui.production.min.js', ].map(async (file) => { try { await prepend(path.resolve(buildPath, file), license); } catch (err) { if (err.code === 'ENOENT') { console.log(`Skipped license for ${file}`); } else { throw err; } } }), ); } async function run() { const extraFiles = process.argv.slice(2); try { // TypeScript await typescriptCopy({ from: srcPath, to: buildPath }); const packageData = await createPackageFile(); await Promise.all( ['./README.md', '../../CHANGELOG.md', '../../LICENSE', ...extraFiles].map(async (file) => { const [sourcePath, targetPath] = file.split(':'); await includeFileInBuild(sourcePath, targetPath); }), ); await addLicense(packageData); await createModulePackages({ from: srcPath, to: buildPath }); } catch (err) { console.error(err); process.exit(1); } } run();