generator-senbochen-cli
Version:
这是一个自定义的yeoman脚手架
62 lines (53 loc) • 1.5 kB
JavaScript
const Generator = require("yeoman-generator");
// const chalk = require("chalk"); // 让console.log带颜色输出
const yosay = require("yosay");
module.exports = class extends Generator {
initializing () {
this.props = {};
}
// 接受用户输入
prompting () {
// Have Yeoman greet the user.
this.log(
yosay(
`Welcome to the grand (
"generator-javascript-plugin"
) generator!`
)
);
const prompts = [
{
type: "input",
name: "name",
message: "Would you like to enable this option?",
default: 'vue-demo'
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
// 写文件
writing () {
// 将templates目录的代码拷贝到目标目录
console.log(this.templatePath("./"), this.destinationPath('./'))
this.fs.copyTpl(
this.templatePath("./"),
this.destinationPath('./'),
{
name: this.props.name,
}
);
}
end () {
this.log(
yosay(
`Welcome to the grand
成功,是一个动宾结构的汉语名词。同“胜利”。意思是指达到或实现某种价值尺度的
事情或事件,从而获得预期结果叫做成功。出自《书·禹贡》:“禹锡玄圭
,告厥成功。”成功是指人或动物通过有意识努力,达到了预期目标。`
)
);
}
};