Add Linux/OSX wrapper script

This script wraps the main code executable for Linux and OS X, redirecting
output to a file and running in the background. An exception is made when help
or version argument are used, not suppressing the output as the bootstrap.js is
expected to write to stdout and immediately exit.

Fixes #77
This commit is contained in:
Daniel Imms
2016-02-03 12:14:45 -08:00
parent 1ba5d60b33
commit 8981819a33

46
resources/common/bin/code.sh Executable file
View File

@@ -0,0 +1,46 @@
#!/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
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" "$@"
else
open -n -b "com.microsoft.VSCode" --args $*
fi
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
else
echo "Could not locate Visual Studio Code executable."
exit 1
fi
fi