feat(firstOpenProject): be based on os and shell version to provide different commands that open project in remote env
This commit is contained in:
@@ -27,13 +27,26 @@ export default class RemoteContainer {
|
||||
* @param path
|
||||
* @param context 用于支持远程项目环境
|
||||
*/
|
||||
async firstOpenProject(host: string, hostname: string, port: number, username: string, path: string) {
|
||||
async firstOpenProject(host: string, hostname: string, port: number, username: string, path: string, context: vscode.ExtensionContext) {
|
||||
if (vscode.env.remoteName) {
|
||||
// 远程环境
|
||||
vscode.commands.executeCommand('workbench.action.terminal.newLocal').then(() => {
|
||||
const terminal = vscode.window.terminals[vscode.window.terminals.length - 1];
|
||||
if (terminal) {
|
||||
// vscode协议
|
||||
terminal.sendText(`code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`)
|
||||
// 根据系统+命令行版本确定命令
|
||||
const semver = require('semver')
|
||||
const powershellVersion = context.globalState.get('powershellVersion')
|
||||
const powershell_semver_compatible_version = semver.coerce(powershellVersion)
|
||||
if (powershellVersion === undefined)
|
||||
terminal.sendText(`code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`)
|
||||
else if (semver.satisfies(powershell_semver_compatible_version, ">=5.1.26100")) {
|
||||
// win & powershell >= 5.1.26100.0
|
||||
terminal.sendText(`code --new-window && code --% --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`)
|
||||
} else {
|
||||
// win & powershell < 5.1.26100.0
|
||||
terminal.sendText(`code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user