()
| 572 | |
| 573 | let localUsername: Promise<string>; |
| 574 | export async function getLocalUsername() { |
| 575 | if (localUsername === undefined) { |
| 576 | localUsername = (async () => { |
| 577 | try { |
| 578 | return os.userInfo().username; |
| 579 | } catch (err) { |
| 580 | if (process.platform !== 'linux') { |
| 581 | throw err; |
| 582 | } |
| 583 | // os.userInfo() fails with VS Code snap install: https://github.com/microsoft/vscode-remote-release/issues/6913 |
| 584 | const result = await runCommandNoPty({ exec: plainExec(undefined), cmd: 'id', args: ['-u', '-n'], output: nullLog }); |
| 585 | return result.stdout.toString().trim(); |
| 586 | } |
| 587 | })(); |
| 588 | } |
| 589 | return localUsername; |
| 590 | } |
| 591 | |
| 592 | export function getEntPasswdShellCommand(userNameOrId: string) { |
| 593 | const escapedForShell = userNameOrId.replace(/['\\]/g, '\\$&'); |
no test coverage detected