vscode/scripts/code.sh

42 lines
921 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2015-11-13 14:39:38 +01:00
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
ROOT=$(dirname $(dirname $(realpath "$0")))
else
ROOT=$(dirname $(dirname $(readlink -f $0)))
fi
2015-11-26 09:29:43 +01:00
function code() {
cd $ROOT
2015-11-13 14:39:38 +01:00
if [[ "$OSTYPE" == "darwin"* ]]; then
2016-08-09 17:56:05 +02:00
NAME=`node -p "require('./product.json').nameLong"`
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
else
NAME=`node -p "require('./product.json').applicationName"`
2016-08-09 17:57:09 +02:00
CODE=".build/electron/$NAME"
fi
2015-11-26 09:29:43 +01:00
# Node modules
test -d node_modules || ./scripts/npm.sh install
2015-11-13 14:39:38 +01:00
2015-11-26 09:29:43 +01:00
# Get electron
test -f "$CODE" || ./node_modules/.bin/gulp electron
2015-11-26 09:29:43 +01:00
2015-11-26 10:07:11 +01:00
# Build
test -d out || ./node_modules/.bin/gulp compile
2015-11-26 10:07:11 +01:00
2015-11-26 09:29:43 +01:00
# Configuration
export NODE_ENV=development
export VSCODE_DEV=1
export VSCODE_CLI=1
2015-11-26 09:29:43 +01:00
export ELECTRON_ENABLE_LOGGING=1
export ELECTRON_ENABLE_STACK_DUMPING=1
# Launch Code
exec "$CODE" . "$@"
2015-11-26 09:29:43 +01:00
}
code "$@"