@@ -10,40 +10,34 @@ VSCODE_PATH="$(dirname "$(dirname "$(realpath "$0")")")"
1010ELECTRON=" $VSCODE_PATH /$NAME .exe"
1111if grep -qi Microsoft /proc/version; then
1212 # in a wsl shell
13- fallback () {
14- # If running under older WSL, don't pass cli.js to Electron as
15- # environment vars cannot be transferred from WSL to Windows
16- # See: https://github.com/Microsoft/BashOnWindows/issues/1363
17- # https://github.com/Microsoft/BashOnWindows/issues/1494
18- " $ELECTRON " " $@ "
19- exit $?
20- }
21- WSL_BUILD=$( uname -r | sed -E ' s/^.+-([0-9]+)-Microsoft/\1/' )
22- # wslpath is not available prior to WSL build 17046
23- # See: https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17046
24- if [ -x /bin/wslpath ]; then
25- WIN_CODE_CMD=$( wslpath -w " $( dirname " $( realpath " $0 " ) " ) /$APP_NAME .cmd" )
26- # make sure the cwd is in the windows fs, otherwise there will be a warning from cmd
27- pushd " $( dirname " $0 " ) " > /dev/null
13+ WSL_BUILD=$( uname -r | sed -E ' s/^.+-([0-9]+)-[Mm]icrosoft/\1/' )
14+ if [ $WSL_BUILD -ge 17063 ] 2> /dev/null; then
15+ # WSLPATH is available since WSL build 17046
16+ # WSLENV is available since WSL build 17063
17+ export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
18+
19+ # use the Remote WSL extension if installed
20+ pushd " $VSCODE_PATH " > /dev/null
2821 WSL_EXT_ID=" ms-vscode-remote.remote-wsl"
29- WSL_EXT_WLOC=$( cmd.exe /c " $WIN_CODE_CMD " --locate-extension $WSL_EXT_ID )
22+ WSL_EXT_WLOC=$( ELECTRON_RUN_AS_NODE=1 " $ELECTRON " " .\resources\app\out\cli.js " --locate-extension $WSL_EXT_ID )
3023 popd > /dev/null
24+
3125 if ! [ -z " $WSL_EXT_WLOC " ]; then
32- # replace \r\n with \n in WSL_EXT_WLOC, get linux path for
26+ # replace \r\n with \n in WSL_EXT_WLOC
3327 WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode.sh
28+ WIN_CODE_CMD=$( wslpath -w " $VSCODE_PATH /bin/$APP_NAME .cmd" )
3429 " $WSL_CODE " $COMMIT $QUALITY " $WIN_CODE_CMD " " $APP_NAME " " $@ "
3530 exit $?
36- elif [ $WSL_BUILD -ge 17063 ] 2> /dev/null; then
37- # Since WSL build 17063, we just need to set WSLENV so that
38- # ELECTRON_RUN_AS_NODE is visible to the win32 process
39- # See: https://docs.microsoft.com/en-us/windows/wsl/release-notes#build-17063
40- export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
31+ else
4132 CLI=$( wslpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
42- else # $WSL_BUILD ∈ [17046, 17063) OR $WSL_BUILD is indeterminate
43- fallback " $@ "
4433 fi
4534 else
46- fallback " $@ "
35+ # If running under older WSL, don't pass cli.js to Electron as
36+ # environment vars cannot be transferred from WSL to Windows
37+ # See: https://github.com/Microsoft/BashOnWindows/issues/1363
38+ # https://github.com/Microsoft/BashOnWindows/issues/1494
39+ " $ELECTRON " " $@ "
40+ exit $?
4741 fi
4842elif [ -x " $( command -v cygpath) " ]; then
4943 CLI=$( cygpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
0 commit comments