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

Breaks if body is left empty #208

Open
andre-brdoch opened this issue Oct 13, 2022 · 4 comments · May be fixed by #223
Open

Breaks if body is left empty #208

andre-brdoch opened this issue Oct 13, 2022 · 4 comments · May be fixed by #223

Comments

@andre-brdoch
Copy link

Problem

It breaks if leaving the body empty:

/home/user/repo/node_modules/word-wrap/index.js:30
  var lines = str.match(re) || [];
                  ^

TypeError: str.match is not a function
    at module.exports (/home/user/repo/node_modules/word-wrap/index.js:30:19)
    at module.exports (/home/user/repo/node_modules/cz-customizable/lib/build-commit.js:82:14)
    at Object.message (/home/user/repo/node_modules/cz-customizable/lib/questions.js:191:33)
    at /home/user/repo/node_modules/run-async/index.js:49:25
    at new Promise (<anonymous>)
    at /home/user/repo/node_modules/run-async/index.js:26:19
    at Object.exports.fetchAsyncQuestionProperty (/home/user/repo/node_modules/cz-customizable/node_modules/inquirer/lib/utils/utils.js:21:29)
    at MergeMapSubscriber.project (/home/user/repo/node_modules/cz-customizable/node_modules/inquirer/lib/ui/prompt.js:70:17)
    at MergeMapSubscriber._tryNext (/home/user/repo/node_modules/cz-customizable/node_modules/rxjs/internal/operators/mergeMap.js:67:27)
    at MergeMapSubscriber._next (/home/user/repo/node_modules/cz-customizable/node_modules/rxjs/internal/operators/mergeMap.js:57:18)

Example input

cz-customizable standalone version
All lines except first will be wrapped after 100 characters.
? Select the type of change that you're committing: feat:     A new feature
? 
Denote the SCOPE of this change (optional): accounts
? Write a SHORT, IMPERATIVE tense description of the change:
 test
? Provide a LONGER description of the change (optional). Use "|" to break new line:
 false
? List any BREAKING CHANGES (optional):
 
? List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:

What is causing this?

This is because the default value for body is false, opposed to other left out values, which are empty strings instead. Have a close look at the Example input above and you will notice the false under body.

This line in build.commit.js will then break this, because word-wrap requires the first argument to be a string (and not a boolean):

let body = wrap(answers.body, wrapOptions) || '';

System

Linux Mint 20.3 Cinnamon
Node v.16.16.0
npm v.8.11.0

@subvertallchris
Copy link

Is there a workaround for this? @leonardoanalista sorry to tag you directly, would love advice!

@subvertallchris subvertallchris linked a pull request May 2, 2023 that will close this issue
@subvertallchris
Copy link

A simple workaround is adding skipQuestions: ["body"] to the .cz-config.js file. This is a shame since body is obviously very useful but if you're in a pinch and need it, it'll get the job done.

@gaao
Copy link

gaao commented Jan 11, 2024

Or you can type spaces in body

@leonardoanalista
Copy link
Member

leonardoanalista commented Feb 12, 2024

Thank you all for contributing 👏 👏 👏
We'll merge #223. I am just waiting on confirmation on the commit message.

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.

4 participants