mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-03 00:09:39 +08:00
1df1034f20
* chore(deps-dev): bump glob from 8.1.0 to 9.2.1 Bumps [glob](https://github.com/isaacs/node-glob) from 8.1.0 to 9.2.1. - [Release notes](https://github.com/isaacs/node-glob/releases) - [Changelog](https://github.com/isaacs/node-glob/blob/main/changelog.md) - [Commits](https://github.com/isaacs/node-glob/compare/v8.1.0...v9.2.1) --- updated-dependencies: - dependency-name: glob dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix: update api * fix * fix * fix path * fix path * update snap * update snap * update snap --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: 栗嘉男 <574980606@qq.com>
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
/* eslint-disable no-await-in-loop, no-console */
|
|
|
|
// ==============================================================================
|
|
// This script is used for converting demo with ES6 `export default` grammar
|
|
// PR: https://github.com/ant-design/ant-design/pull/34843
|
|
// ==============================================================================
|
|
|
|
const path = require('path');
|
|
const glob = require('glob');
|
|
const fs = require('fs-extra');
|
|
const chalk = require('chalk');
|
|
|
|
(async () => {
|
|
console.time('Execution...');
|
|
|
|
const demoFiles = glob.globSync(path.join(process.cwd(), 'components/*/demo/*.md'));
|
|
|
|
const tmpFolder = path.resolve('components', '~tmp');
|
|
await fs.remove(tmpFolder);
|
|
await fs.ensureDir(tmpFolder);
|
|
|
|
function getConvertedDemo(content) {
|
|
return content.replace(
|
|
/ReactDOM.render\(([\S\s]*),\s*mountNode,?(\n)?\);/g,
|
|
'export default () => ($1$2);',
|
|
);
|
|
}
|
|
|
|
for (let i = 0; i < demoFiles.length; i += 1) {
|
|
const demoPath = demoFiles[i];
|
|
console.log(chalk.white(`Converting demos(${i + 1}/${demoFiles.length}): ${demoPath}`));
|
|
const content = await fs.readFile(demoPath, 'utf8');
|
|
const newContent = getConvertedDemo(content);
|
|
await fs.writeFile(demoPath, newContent, 'utf8');
|
|
}
|
|
console.log(chalk.green(`All demos(${i + 1}/${demoFiles.length}) done.`));
|
|
})();
|