code.sh is broken in WSL after commit "run code wsl in dev ". Fixes #72263

This commit is contained in:
Martin Aeschlimann 2019-07-29 16:02:58 +02:00
parent fb5c4e59e4
commit c94b2703c5

View file

@ -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 "$@"
code "$@"