How do I run commands ? eg npm run dev
#492
Answered
by
jeremytenjo
jeremytenjo
asked this question in
Q&A
-
HI, Is it possible to run commands? eg npm run dev If so, can we run multiple concurrently in the same dashboard ? |
Beta Was this translation helpful? Give feedback.
Answered by
jeremytenjo
Dec 14, 2021
Replies: 1 comment
-
Figured it out const restartCommand = () => {
shellRef.current.kill()
startCommand()
}
const startCommand = () => {
const commandArgs = command.split(' ')
commandArgs.shift()
const shell = spawn('npm', commandArgs)
// https://www.freecodecamp.org/news/node-js-child-processes-everything-you-need-to-know-e69498fe970a/
shell.stdout.on('data', (data) => {
const lines = data.toString('utf8')
setOutput(lines)
})
shell.on('error', (error) => {
setOutput(error.toString())
})
shellRef.current = shell
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
jeremytenjo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Figured it out