forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopyFiles.mjs
69 lines (61 loc) · 1.64 KB
/
copyFiles.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* 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((file) =>
includeFileInBuild(file),
),
);
await addLicense(packageData);
await createModulePackages({ from: srcPath, to: buildPath });
} catch (err) {
console.error(err);
process.exit(1);
}
}
run();