Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ifExists seems to not working? #29

Open
tunnckoCore opened this issue Oct 19, 2019 · 2 comments · May be fixed by verbose/verb-repo-helpers#4
Open

ifExists seems to not working? #29

tunnckoCore opened this issue Oct 19, 2019 · 2 comments · May be fixed by verbose/verb-repo-helpers#4

Comments

@tunnckoCore
Copy link
Contributor

tunnckoCore commented Oct 19, 2019

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
Copy link
Contributor Author

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 pushed a commit to tunnckoCore/verb-repo-helpers that referenced this issue Oct 19, 2019
tunnckoCore added a commit to tunnckoCore/opensource that referenced this issue Oct 19, 2019
patch for verbose/verb-generate-readme#29 and verbose/verb-repo-helpers#4

fixes #63

Signed-off-by: Charlike Mike Reagent <opensource@tunnckocore.com>
@tunnckoCore
Copy link
Contributor Author

tunnckoCore commented Oct 19, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant