Skip to content

Commit

Permalink
Copy translations.json to @mui/docs build folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Mar 13, 2024
1 parent d93226a commit 675a013
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/mui-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build:node": "node ../../scripts/build.mjs node",
"build:stable": "node ../../scripts/build.mjs stable",
"build:types": "node ../../scripts/buildTypes.mjs",
"build:copy-files": "node ../../scripts/copyFiles.mjs",
"build:copy-files": "node ../../scripts/copyFiles.mjs ./src/translations/translations.json:./translations/translations.json",
"prebuild": "rimraf build",
"release": "pnpm build && pnpm publish",
"test": "exit 0"
Expand Down
7 changes: 4 additions & 3 deletions scripts/copyFiles.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ async function run() {
const packageData = await createPackageFile();

await Promise.all(
['./README.md', '../../CHANGELOG.md', '../../LICENSE', ...extraFiles].map((file) =>
includeFileInBuild(file),
),
['./README.md', '../../CHANGELOG.md', '../../LICENSE', ...extraFiles].map(async (file) => {
const [sourcePath, targetPath] = file.split(':');
await includeFileInBuild(sourcePath, targetPath);
}),
);

await addLicense(packageData);
Expand Down
12 changes: 10 additions & 2 deletions scripts/copyFilesUtils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ import glob from 'fast-glob';
const packagePath = process.cwd();
const buildPath = path.join(packagePath, './build');

export async function includeFileInBuild(file) {
/**
* Copies a file into the build directory. By default it copies it under the same
* base name in the root, but you can provide a second argument to specify a
* different subpath.
* @param {string} file source file path
* @param {string=} target target file path
* @returns {Promise<void>}
*/
export async function includeFileInBuild(file, target = path.basename(file)) {
const sourcePath = path.resolve(packagePath, file);
const targetPath = path.resolve(buildPath, path.basename(file));
const targetPath = path.resolve(buildPath, target);
await fse.copy(sourcePath, targetPath);
console.log(`Copied ${sourcePath} to ${targetPath}`);
}
Expand Down

0 comments on commit 675a013

Please sign in to comment.