Q: How to run command in TS? I tried to run command from TS
function executeCommand(command : string, callback: (error: ExecException, stdout : string, stderr : string) => void): void  {
    const path= path.join(vscode.workspace.rootPath,"products");

    exec(command, {cwd: '${path}'}, callback);
}

       const command = ({
            'darwin': ``,
            'linux': `cf env`,
            'win32': `cf env`
        } as any)[platform];


 executeCommand(command, (error, stdout, stderr) => {
            if (error) {
                console.warn(error);
            }
      ...
 }

I want to run the command cf env on different path so I tried to change the cwd
When I did it I got an error:

spawn C:\WINDOWS\system32\cmd.

When I removed the cwd then it worked but I need to use the "CWD" option

A: What you have done is try to set the path to the literal string: ${path}.
To use string interpolation, you have to use backticks instead of single quotes, like so:
`${path}` // resolves to the path

But since you're not using the interpolation for anything, you can just put the path directly into the function:
exec(command, {cwd: path}, callback);

The error you're gettting is because the path ${path} is invalid, cmd doesn't start.
