0

I have been using shell js to execute a git command in a node js file as follows:

 if (shell.exec(`git commit -m "${messageEmoji} ${messageType} : ${commitMsg}"`).code !== 0) {
        console.log('Error: Git commit failed');
        exit(1);
      }

However it keeps exiting with status code 1. How do I execute it then?

I have already tried running it through the commands mentioned in docs. p.s. : my OS is windows 10

  • Hi, welcome to SO. Please take a bit more time to debug your issue. For example: did you make sure you had staged changes before running `git commit` (running git commit wthout changes will produce an error) ? does your code work if you replace your commit message by a simple string, e.g: shell.exec(\`git commit -m "test message"\`) ? have you checked the output on stdout and stderr of that execution ? etc ... – LeGEC May 08 '23 at 06:14
  • Yeah . It just got fixed. There was some issue in the husky hooks . – Soumya Sagar May 09 '23 at 07:56
  • I’m voting to close this question because the OP fixed it, and the actual issue wasn't related to shelljs or git, but with some framework (husky) not mentioned in the question – LeGEC May 09 '23 at 08:57

0 Answers0