jondot / hygen

The simple, fast, and scalable code generator that lives in your project.

Home Page:http://www.hygen.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New install doesn't load templates from `_templates`

mimiflynn opened this issue · comments

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.

BTW, I'm on a macOS 12.5.1

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(_))
}

Thanks, I'm looking into it

This is now fixed in v6.2.11 which was recently released. Please update & thanks for opening an issue ❤️

Working now, thanks!