fix(cli): fix some bugs of create-vant-cli-app

This commit is contained in:
陈嘉涵
2020-01-16 19:28:26 +08:00
parent 5bb9a31e28
commit df6edc4864
7 changed files with 17 additions and 26 deletions

View File

@@ -44,21 +44,21 @@ export class VanGenerator extends Generator {
this.fs.copy(join(TEMPLATES, from), this.destinationPath(to || from));
};
const copyTpl = (name: string) => {
const copyTpl = (name: string, target?: string) => {
this.fs.copyTpl(
join(TEMPLATES, name),
this.destinationPath(name),
this.destinationPath(target || name),
this.inputs
);
};
copy('.gitignore');
copy('.eslintignore');
copyTpl('package.json.tpl', 'package.json');
copyTpl('vant.config.js');
copy('babel.config.js');
copy('gitignore.tpl', '.gitignore');
copy('eslintignore.tpl', '.eslintignore');
copy('src/**/*', 'src');
copy('docs/**/*', 'docs');
copyTpl('package.json');
copyTpl('vant.config.js');
}
install() {

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node
import inquirer from 'inquirer';
import { mkdirSync, existsSync } from 'fs-extra';
import { ensureDir } from 'fs-extra';
import { VanGenerator } from './generator';
const PROMPTS = [
@@ -13,15 +15,10 @@ const PROMPTS = [
export default async function run() {
const { name } = await inquirer.prompt(PROMPTS);
if (!existsSync(name)) {
mkdirSync(name);
}
ensureDir(name);
const generator = new VanGenerator(name);
return new Promise(resolve => {
generator.run(resolve);
});
generator.run();
}
run();