From c94b2703c5d7688d74473b579844fcded5269589 Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 29 Jul 2019 16:02:58 +0200 Subject: [PATCH] code.sh is broken in WSL after commit "run code wsl in dev ". Fixes #72263 --- scripts/code.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/code.sh b/scripts/code.sh index b0b112bc237e7..830271adff60a 100755 --- a/scripts/code.sh +++ b/scripts/code.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -e +set -ex if [[ "$OSTYPE" == "darwin"* ]]; then realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; } @@ -58,15 +58,21 @@ function code() { function code-wsl() { # in a wsl shell - local WIN_CODE_CLI_CMD=$(wslpath -w "$ROOT/scripts/code-cli.bat" 2>/dev/null) - if ! [ -z "$WIN_CODE_CLI_CMD" ]; then + ELECTRON="$ROOT/.build/electron/Code - OSS.exe" + if [ -f "$ELECTRON" ]; then + local CWD=$(pwd) + cd $ROOT + export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV local WSL_EXT_ID="ms-vscode-remote.remote-wsl" - local WSL_EXT_WLOC=$(cmd.exe /c "$WIN_CODE_CLI_CMD" --locate-extension $WSL_EXT_ID) - if ! [ -z "$WSL_EXT_WLOC" ]; then + local WSL_EXT_WLOC=$(ELECTRON_RUN_AS_NODE=1 "$ROOT/.build/electron/Code - OSS.exe" "out/cli.js" --locate-extension $WSL_EXT_ID) + cd $CWD + if [ -n "$WSL_EXT_WLOC" ]; then # replace \r\n with \n in WSL_EXT_WLOC local WSL_CODE=$(wslpath -u "${WSL_EXT_WLOC%%[[:cntrl:]]}")/scripts/wslCode-dev.sh $WSL_CODE "$ROOT" "$@" exit $? + else + echo "Remote WSL not installed, trying to run VSCode in WSL." fi fi } @@ -74,4 +80,4 @@ function code-wsl() if ! [ -z ${IN_WSL+x} ]; then code-wsl "$@" fi -code "$@" \ No newline at end of file +code "$@"