verb-generate-readme icon indicating copy to clipboard operation
verb-generate-readme copied to clipboard

ifExists seems to not working?

Open tunnckoCore opened this issue 5 years ago • 2 comments

Super weird... as always :D

{%= ifExists([process.cwd() + '/.verb.head.md'], include(process.cwd() + '/.verb.head.md')) %}

Fails by saying that it cannot include .verb.head.md beacause it's not found.

~~I forgot, where is exactly this helper? ~~

Found it, it's https://github.com/verbose/verb-repo-helpers.

edit: Oooh. Got it, it's because include is also called, no matter of the if condition.

/cc @doowb @jonschlinkert

tunnckoCore avatar Oct 19 '19 12:10 tunnckoCore

Okay, the fix is working as I thought.

Put the include inside function.

{%= ifExists([process.cwd() + '/.verb.head.md'], () => include(process.cwd() + '/.verb.head.md')) %}

But the ifExists should be changed.

val = typeof val === 'function' ? val() : val;

tunnckoCore avatar Oct 19 '19 13:10 tunnckoCore

Ooh, and another solution that may appear is

{% if (ifExists([process.cwd() + '/.verb.md'], true)) { %}

{%= include(process.cwd() + '/.verb.md') %}

{% } %}

but it doesn't work either.

tunnckoCore avatar Oct 19 '19 14:10 tunnckoCore