generator-dlw-ui5
Version:
generator delaware sapui5
47 lines (42 loc) • 1.13 kB
JavaScript
const Generator = require("yeoman-generator"),
path = require("path"),
glob = require("glob");
module.exports = class extends Generator {
constructor(args, opts) {
super(args, opts);
this.log("Initializing...");
}
prompting() {
return this.prompt([
{
type: "input",
name: "name",
message: "Enter new application name: ",
},
]).then((answers) => {
if (answers.newdir) {
this.destinationRoot(`${answers.name}`);
}
this.config.set(answers);
this.config.set("namespaceURI", answers.name.split(".").join("/"));
});
}
async writing() {
const oConfig = this.config.getAll();
this.destinationRoot(oConfig.name);
this.sourceRoot(path.join(__dirname, "templates"));
glob
.sync("**", {
cwd: this.sourceRoot(),
nodir: true,
})
.forEach((file) => {
const sOrigin = this.templatePath(file);
const sTarget = this.destinationPath(
file.replace(/^gen/, "").replace(/gen/, "/")
);
this.fs.copyTpl(sOrigin, sTarget);
});
}
};
;