Skip to content

Commit

Permalink
Add Linux/OSX wrapper script
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tyriar committed Feb 3, 2016
1 parent 1ba5d60 commit 8981819
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions resources/common/bin/code.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8981819

Please sign in to comment.