Move arg parsing to launcher.js

This commit is contained in:
Daniel Imms
2016-02-08 21:59:49 -08:00
parent f71475856b
commit 84ca9b76c7
3 changed files with 68 additions and 62 deletions

View File

@@ -1,46 +1,32 @@
#!/usr/bin/env bash
VSCODE_CWD=$(pwd)
while getopts ":hv-:" opt; do
case $opt in
-)
case $OPTARG in
help|version)
ENABLE_OUTPUT=1
;;
esac
;;
h|v)
ENABLE_OUTPUT=1
;;
esac
done
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ $ENABLE_OUTPUT ]; then
if [ -x "/Applications/Visual Studio Code.app" ]; then
VSCODE_PATH="/Applications/Visual Studio Code.app"
elif [ -x "$HOME/Applications/Visual Studio Code.app" ]; then
VSCODE_PATH="$HOME/Applications/Visual Studio Code.app"
else
echo "Could not locate Visual Studio Code.app"
exit 1
fi
"$VSCODE_PATH/Contents/MacOS/Electron" "$@"
if [ -x "/Applications/Visual Studio Code.app" ]; then
VSCODE_DIR="/Applications/Visual Studio Code.app/Contents/MacOS"
elif [ -x "$HOME/Applications/Visual Studio Code.app" ]; then
VSCODE_DIR="$HOME/Applications/Visual Studio Code.app/Contents/MacOS"
else
open -n -b "com.microsoft.VSCode" --args $*
echo "Could not locate Visual Studio Code.app"
exit 1
fi
ELECTRON_FILE="Electron"
else
VSCODE_PATH="/usr/share/code/Code"
if [ -x $VSCODE_PATH ]; then
if [ $ENABLE_OUTPUT ]; then
"$VSCODE_PATH" "$@"
exit $?
else
nohup $VSCODE_PATH "$@" > ~/.vscode/nohup.out 2>&1 &
fi
VSCODE_DIR="/usr/share/code"
if [ -x "$VSCODE_DIR/Code" ]; then
ELECTRON_FILE="Code"
elif [ -x "$VSCODE_DIR/Code - OSS" ]; then
ELECTRON_FILE="Code - OSS"
else
echo "Could not locate Visual Studio Code executable."
exit 1
fi
fi
VSCODE_LAUNCHER="$VSCODE_DIR/launcher.js"
ATOM_SHELL_INTERNAL_RUN_AS_NODE=1 VSCODE_PATH="$VSCODE_DIR/$ELECTRON_FILE" \
"$VSCODE_DIR/$ELECTRON_FILE" $VSCODE_LAUNCHER "$@"
exit $?