-
Notifications
You must be signed in to change notification settings - Fork 49
/
invoke-code
executable file
·36 lines (29 loc) · 1.25 KB
/
invoke-code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
#
# Adapted from the `code` command that ships with VS Code for Bash users, stripped down
# so that it always calls the Windows-side Code.exe even when the "Remote - WSL" extension
# is installed (because otherwise we break our ability to install extensions). It will
# fall back to just calling `code` with the command line options when not in WSL.
#
# Original copyright header:
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://github.com/microsoft/vscode/blob/afd102cbd2e17305a510701d7fd963ec2528e4ea/LICENSE.txt for license information.
CODE_PATH="$(which code)"
if [ -z "${CODE_PATH}" ]; then
if [ -n "${WSL_DISTRO_NAME}" ]; then
echo 2>&1 "error(1): Cannot find 'code' on the path; is VS Code installed in Windows?"
else
echo 2>&1 "error(1): Cannot find 'code' on the path; is VS Code installed?"
fi
exit 1
fi
if [ -n "${WSL_DISTRO_NAME}" ]; then
VSCODE_PATH="$(dirname "$(dirname "$(realpath "${CODE_PATH}")")")"
ELECTRON="${VSCODE_PATH}/Code.exe"
export WSLENV="ELECTRON_RUN_AS_NODE/w:$WSLENV"
CLI=$(wslpath -m "$VSCODE_PATH/resources/app/out/cli.js")
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
else
code "$@"
fi
exit $?