generator-min-app
Version:
hcy system layout and pages
58 lines (49 loc) • 1.42 kB
JavaScript
;
const Generator = require("yeoman-generator");
const chalk = require("chalk");
const yosay = require("yosay");
const fs = require("fs");
const path = require("path");
// Copy all files and folders from the template directory to the destination directory
const copyFiles = (templateDir, destinationDir) => {
fs.readdirSync(templateDir).forEach(file => {
const sourcePath = path.join(templateDir, file);
const destinationPath = path.join(destinationDir, file);
const stats = fs.statSync(sourcePath);
if (stats.isDirectory()) {
fs.mkdirSync(destinationPath);
copyFiles(sourcePath, destinationPath);
} else {
fs.copyFileSync(sourcePath, destinationPath);
}
});
};
module.exports = class extends Generator {
prompting() {
// Have Yeoman greet the user.
this.log(
yosay(
`Welcome to the dandy ${chalk.red("generator-hcy-min-app")} generator!`
)
);
const prompts = [
{
type: "confirm",
name: "someAnswer",
message: "Would you like to enable this option?",
default: true
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
writing() {
copyFiles(this.templatePath(), this.destinationPath());
}
install() {
this.installDependencies();
}
};
// Your new code here