Skip to content
Advertisement

Running terminal commands in VS code

Is there anyway to run terminal commands using playwright(javascript)? Can there be a way to access the terminal through VScode? What I am trying to achieve is instead of having steps 1-10 being login steps with username and password. I have a command and or code that can reach the terminal, login and access my Org? I attached the code of the command I am trying to use.

SFDX force:org:open -u “Test@test.com”

I tried a few scenarios but cant access the terminal through the code.

What bash/shell commands would be of use for this scenario? Cant run the SFDX command in vs code without it running in the terminal.. I want it to run the SFDX command first step 1 run the command and then run the rest of the script after.

Advertisement

Answer

Since you have a package.json I usually add a few extra scripts in it to help me in cases like that.

So there’s two ways to run those scripts using npm or yarn:

  1. add the item to the scripts section in the package.json like this:
JavaScript

and then run :

JavaScript

or

JavaScript

The second one (which I recommend the most) is to create a script and then run that script from the package.json, like this:

script file -> setup.sh (in this case is a shell script file but it could be a .bat for windows or powershell instead:

JavaScript

and then your package.json:

JavaScript

This is a sample of a scripts section of one of my projects. As you can see I have both cases here:

JavaScript

There is also preinstall and postinstall scripts which would run before and after npm install respectfully.

Hope that helps!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement