1

My extension opens a terminal to run a specific command.

Openning the terminal is not a problem, however, specifying the terminal path is.

I am working on Windows, but my default terminal is git bash. As a consequence, results of path.join, which contain single backslashes (windows...), used in the command, does not work with git bash.

I want to make sure the windows cmd.exe terminal is used to avoid this problem (all users are on windows, this is not problematic).

The documentation says that we can specify a terminal path. I tried to provide the path of cmd.exe obtained from process.env.COMSPEC, without success:

console.log(process.env.COMSPEC)
const terminal = vscode.window.createTerminal(
    name = "Create Projet", shellPath = process.env.COMSPEC)

Throws:

C:\Windows\system32\cmd.exe

ReferenceError: shellPath is not defined at c:\Users\user\Documents\template-python-cli\vscode\project\out\extension.js:58:55 at processTicksAndRejections (internal/process/task_queues.js:93:5) at async l._executeContributedCommand (c:\Users\user\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:94:111644)

But as the log above says, the value exists.

How can I tell the extension to open cmd.exe with createTerminal ?

rioV8
  • 24,506
  • 3
  • 32
  • 49
Itération 122442
  • 2,644
  • 2
  • 27
  • 73

1 Answers1

0

Nevermind, unfortunately too used to the way named parameters work in Python. Anyway, solution is:

const terminal = vscode.window.createTerminal("Create Projet",
                    process.env.COMSPEC)

This is kind of a duplicate of https://stackoverflow.com/a/42108988/6213883

Itération 122442
  • 2,644
  • 2
  • 27
  • 73