0

I'm not sure if this is specific to npm scripts, or to visual studio code, or to shell scripting in general so please bear with me.

The setup is like this. I have a react project running through Visual Studio Code on a windows environment and in the scripts section of my package.json file I have custom script that looks like this

 "scripts": {
    "prestart": "prestart.sh",
    "start": "react-scripts start",
    //Rest of the scripts
  },

For the sake of simplicity, lets just say the prestart.sh file looks like this

echo "Hello World"
sleep 10
exit

What happens when I run "npm start" is that "prestart.sh" runs then "react-scripts start" runs. This is exactly what I want. The problem is that, in my environment, the Visual Studio Code terminal is spawning a \Git\bin\bash console to run the shell script and the echos are all showing up on that spawned console. I would like them to just show up on the Visual Studio Code terminal or output tabs.

enter image description here

Is there a way to pipe the echos from the prestart.sh script into the terminal or output tabs for Visual Studio? If there is, how do I do it?

Beard Tony
  • 23
  • 10
  • why don't you have the terminal in VSC a bash shell – rioV8 Oct 30 '20 at 04:12
  • The terminal I am using in VSC is a bash shell. If I run it directly from the terminal by typing "./prestart.sh" it runs it all in the VSC shell just fine without spawning off a new one. It's when I type "npm start" which hooks into all of those npm scripts and that seems to be making the new console spawn. I'm not sure what it's doing internally that causes that. – Beard Tony Oct 30 '20 at 04:40
  • you have a `C:\` path, looks not very bash shell to me – rioV8 Oct 30 '20 at 04:43
  • This is a windows environment. The bash shell is Git bash. It's saved at C:\Program Files\Git\bin\bash.exe – Beard Tony Oct 30 '20 at 05:00

0 Answers0