22#
33# Copyright (c) Microsoft Corporation. All rights reserved.
44# Licensed under the MIT License. See License.txt in the project root for license information.
5+ COMMIT=" @@COMMIT@@"
6+ APP_NAME=" @@APPNAME@@"
57
6- NAME=" @@NAME@@"
7- VSCODE_PATH=" $( dirname " $( dirname " $( realpath " $0 " ) " ) " ) "
8- ELECTRON=" $VSCODE_PATH /$NAME .exe"
9- if grep -q Microsoft /proc/version; then
10- if [ -x /bin/wslpath ]; then
11- # On recent WSL builds, we just need to set WSLENV so that
12- # ELECTRON_RUN_AS_NODE is visible to the win32 process
13- export WSLENV=ELECTRON_RUN_AS_NODE/w:$WSLENV
14- CLI=$( wslpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
15- else
16- # If running under older WSL, don't pass cli.js to Electron as
17- # environment vars cannot be transferred from WSL to Windows
18- # See: https://github.com/Microsoft/BashOnWindows/issues/1363
19- # https://github.com/Microsoft/BashOnWindows/issues/1494
20- " $ELECTRON " " $@ "
8+ set -e
9+
10+ if grep -qi Microsoft /proc/version; then
11+ # in a wsl shell
12+ WIN_CODE_CMD=$( wslpath -w " $( dirname " $( realpath " $0 " ) " ) /$APP_NAME .cmd" )
13+
14+ WSL_EXT_ID=" ms-vscode.remote-wsl"
15+ WSL_EXT_WLOC=$( cmd.exe /c " $WIN_CODE_CMD " --locate-extension $WSL_EXT_ID )
16+ if ! [ -z " $WSL_EXT_WLOC " ]; then
17+ # replace \r\n with \n in WSL_EXT_WLOC, get linux path for
18+ WSL_CODE=$( wslpath -u " ${WSL_EXT_WLOC%% [[:cntrl:]]} " ) /scripts/wslCode.sh
19+ $WSL_CODE $COMMIT " $WIN_CODE_CMD " " $APP_NAME " " $@ "
2120 exit $?
2221 fi
23- elif [ -x " $( command -v cygpath) " ]; then
22+ fi
23+
24+ if [ -x " $( command -v cygpath) " ]; then
2425 CLI=$( cygpath -m " $VSCODE_PATH /resources/app/out/cli.js" )
2526else
2627 CLI=" $VSCODE_PATH /resources/app/out/cli.js"
2728fi
29+ ELECTRON=" $VSCODE_PATH /$NAME .exe"
2830ELECTRON_RUN_AS_NODE=1 " $ELECTRON " " $CLI " " $@ "
29- exit $?
31+ exit $?
0 commit comments