New install doesn't load templates from `_templates`
mimiflynn opened this issue · comments
Mimi Flynn commented
Using hygen
on a new computer with a fresh install and upon hygen init self
then hygen generator new --name things
I get an error:
% hygen init self
Loaded templates: /usr/local/lib/node_modules/hygen/src/templates
added: _templates/generator/help/index.ejs.t
added: _templates/generator/with-prompt/hello.ejs.t
added: _templates/generator/with-prompt/prompt.ejs.t
added: _templates/generator/new/hello.ejs.t
added: _templates/init/repo/new-repo.ejs.t
works great but then:
% hygen generator new --name things
Loaded templates: /usr/local/lib/node_modules/hygen/src/templates
Error: I can't find action 'new' for generator 'generator'.
You can try:
1. 'hygen init self' to initialize your project, and
2. 'hygen generator new --name generator' to build the generator you wanted.
Check out the quickstart for more: http://www.hygen.io/docs/quick-start
Hygen v6.2.10
Available actions:
init: init repo, init self
hygen
appears to still look for templates in the global directory and not in the local _templates
directory it had just created upon init.
Mimi Flynn commented
BTW, I'm on a macOS 12.5.1
dmitriybo commented
The error is in the config-resolver.ts file.
const resolve = (cwd: string, templates: string | undefined) => {
return [
path.resolve(cwd, templates), // Everything works without this line
process.env.HYGEN_TMPLS,
path.resolve(cwd, '_templates'),
].find((_) => _ && fs.existsSync(_))
}
Dotan J. Nahum commented
Thanks, I'm looking into it
Dotan J. Nahum commented
This is now fixed in v6.2.11 which was recently released. Please update & thanks for opening an issue ❤️
Mimi Flynn commented
Working now, thanks!