I have all the files in templates directory that needs to copy to destination path when i run command yo my-generator and in below index.js writing method i tried to copy templates to templates it throws error , what is correct way to achieve this tassk using yeoman ?
index.js
'use strict';
const Generator = require('yeoman-generator');
const chalk = require('chalk');
const yosay = require('yosay');
module.exports = class extends Generator {
prompting() {
// Have Yeoman greet the user.
this.log(
yosay(
`Welcome to the epic ${chalk.red(
"generator-cvsdigital-sdk-nodeapp-generator"
)} generator!`
)
);
const prompts = [
{
type: "input",
name: "name",
message: "Your project name",
// Defaults to the project's folder name if the input is skipped
default: this.appname
}
];
return this.prompt(prompts).then(props => {
// To access props later use this.props.someAnswer;
this.props = props;
});
}
writing() {
this.fs.copyTpl(
this.templatePath("package.json"),
this.destinationPath("package.json")
);
this.fs.copyTpl(
this.templatePath("templates"),
this.destinationPath("templates")
);
}
install() {
this.installDependencies();
}
};
error
AssertionError [ERR_ASSERTION]: Trying to copy from a source that does not exist: /Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/generators/app/templates/templates
at EditionInterface.exports.copy (/Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/mem-fs-editor/lib/actions/copy.js:48:3)
at EditionInterface.module.exports [as copyTpl] (/Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/mem-fs-editor/lib/actions/copy-tpl.js:29:8)
at module.exports.writing (/Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/generators/app/index.js:38:13)
at Object.<anonymous> (/Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/yeoman-generator/lib/index.js:399:25)
at /Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/run-async/index.js:49:25
at new Promise (<anonymous>)
at /Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/run-async/index.js:26:19
at self.env.runLoop.add.completed (/Users/z243545/Documents/Projects/Microservices/generator-cvsdigital-sdk-nodeapp-generator/node_modules/yeoman-generator/lib/index.js:400:11)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
