Skip to content

Instantly share code, notes, and snippets.

@divyanshu013
Created March 18, 2019 13:54
Show Gist options
  • Save divyanshu013/3547297f58224ee34271490ac4fb5b6e to your computer and use it in GitHub Desktop.
Save divyanshu013/3547297f58224ee34271490ac4fb5b6e to your computer and use it in GitHub Desktop.
Final generator with writing method added
const Generator = require('yeoman-generator');
module.exports = class extends Generator {
// ...
writing() {
this.log('Writing files... 📝');
const { type, name } = this.answers;
if (type === 'screen') {
this.fs.copyTpl(
this.templatePath('component.js'),
this.destinationPath(`components/${name}.js`),
{
name,
},
);
} else {
this.fs.copyTpl(
this.templatePath('module.js'),
this.destinationPath(`modules/${name.toLowerCase()}.js`),
{
name,
},
);
}
}
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment