Skip to content

Commit

Permalink
use umi@3
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Jun 27, 2022
1 parent 5f8b143 commit 36fda2f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions lib/BasicGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ class BasicGenerator extends Generator {
dot: true,
})
.filter(filterFiles)
.filter(file => !file.includes('welcomeImgs'))
.forEach(file => {
.filter((file) => !file.includes('welcomeImgs'))
.forEach((file) => {
debug(`copy ${file}`);
const filePath = this.templatePath(file);
if (statSync(filePath).isFile()) {
Expand Down
12 changes: 7 additions & 5 deletions lib/generators/ant-design-pro/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function log(...args) {

function globList(patternList, options) {
let fileList = [];
patternList.forEach(pattern => {
patternList.forEach((pattern) => {
fileList = [...fileList, ...glob.sync(pattern, options)];
});

Expand Down Expand Up @@ -55,14 +55,14 @@ class AntDesignProGenerator extends BasicGenerator {
default: 'simple',
},
];
return this.prompt(prompts).then(props => {
return this.prompt(prompts).then((props) => {
this.prompts = props;
});
}
}

async writing() {
const { language = 'TypeScript', allBlocks, } = this.prompts;
const { language = 'TypeScript', allBlocks } = this.prompts;

const isTypeScript = language === 'TypeScript';
const projectName = this.opts.name || this.opts.env.cwd;
Expand All @@ -79,6 +79,8 @@ class AntDesignProGenerator extends BasicGenerator {
if (allBlocks === 'complete') {
log(`🙈 complete mode can only use the version of antd@4`);
gitArgs.push('--branch', 'all-blocks');
} else {
gitArgs.push('--branch', 'umi@3');
}

gitArgs.push(projectName);
Expand Down Expand Up @@ -135,7 +137,7 @@ class AntDesignProGenerator extends BasicGenerator {

log('[JS] Clean up...');
const removeTsFiles = globList(['tsconfig.json', '**/*.d.ts'], envOptions);
removeTsFiles.forEach(filePath => {
removeTsFiles.forEach((filePath) => {
const targetPath = path.resolve(projectPath, filePath);
fs.removeSync(targetPath);
});
Expand Down Expand Up @@ -172,7 +174,7 @@ class AntDesignProGenerator extends BasicGenerator {
const ignoreFiles = pkg['create-umi'].ignore;
const fileList = globList(ignoreFiles, envOptions);

fileList.forEach(filePath => {
fileList.forEach((filePath) => {
const targetPath = path.resolve(projectPath, filePath);
fs.removeSync(targetPath);
});
Expand Down
8 changes: 4 additions & 4 deletions lib/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ const yeoman = require('yeoman-environment');

const generators = fs
.readdirSync(`${__dirname}/generators`)
.filter(f => !f.startsWith('.'))
.map(f => {
.filter((f) => !f.startsWith('.'))
.map((f) => {
return {
name: `${f.padEnd(15)} - ${chalk.gray(require(`./generators/${f}/meta.json`).description)}`,
value: f,
Expand All @@ -18,7 +18,7 @@ const generators = fs
});

const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), args = {} }) => {
return new Promise(resolve => {
return new Promise((resolve) => {
if (name) {
mkdirp.sync(name);
cwd = path.join(cwd, name);
Expand Down Expand Up @@ -48,7 +48,7 @@ const runGenerator = async (generatorPath, { name = '', cwd = process.cwd(), arg
});
};

const run = async config => {
const run = async (config) => {
process.send && process.send({ type: 'prompt' });
process.emit('message', { type: 'prompt' });

Expand Down

0 comments on commit 36fda2f

Please sign in to comment.