1

I'm trying to execute npm script using js

Have following in package.json

"script": {
   "commit": "git commit -m {dynamic message}"
}

And in the JS i want to reach to this script, execute it and send dynamic message to it

2
  • And what is your problem when you try to do that? Commented Sep 15, 2021 at 6:29
  • Idk how to execute it from the JS function thats the issue Commented Sep 15, 2021 at 6:30

1 Answer 1

2

This will run commands it could be any command

const { execSync } = require('child_process')
execSync("some-command")
Sign up to request clarification or add additional context in comments.

2 Comments

I need to execute commit from the JS file programatically not from the CLI
Look at this API nodejs.org/api/… you can run commands through this

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.