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

Andon Mitev
  • 1,354
  • 1
  • 11
  • 30

1 Answers1

2

This will run commands it could be any command

const { execSync } = require('child_process')
execSync("some-command")
Jack
  • 788
  • 3
  • 13
  • I need to execute commit from the JS file programatically not from the CLI – Andon Mitev Sep 15 '21 at 06:32
  • Look at this API https://nodejs.org/api/child_process.html#child_process_child_process_execsync_command_options you can run commands through this – Jack Sep 15 '21 at 06:33