Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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