vscode/scripts/code.sh

54 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2015-11-13 13:39:38 +00:00
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
2017-02-21 20:22:01 +00:00
ROOT=$(dirname "$(dirname "$(realpath "$0")")")
2015-11-13 13:39:38 +00:00
else
2017-02-21 20:22:01 +00:00
ROOT=$(dirname "$(dirname "$(readlink -f $0)")")
2015-11-13 13:39:38 +00:00
fi
2015-11-26 08:29:43 +00:00
function code() {
2017-02-21 20:22:01 +00:00
cd "$ROOT"
2015-11-13 13:39:38 +00:00
if [[ "$OSTYPE" == "darwin"* ]]; then
2016-08-09 15:56:05 +00: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 15:57:09 +00:00
CODE=".build/electron/$NAME"
fi
2015-11-26 08:29:43 +00:00
# Node modules
2017-11-16 09:47:02 +00:00
test -d node_modules || yarn
2015-11-13 13:39:38 +00:00
2015-11-26 08:29:43 +00:00
# Get electron
2017-11-16 13:43:41 +00:00
node build/lib/electron.js || ./node_modules/.bin/gulp electron
2015-11-26 08:29:43 +00:00
2018-01-29 21:04:27 +00:00
# Manage built-in extensions
if [[ "$1" == "--builtin" ]]; then
exec "$CODE" build/builtin
return
fi
2018-01-29 11:23:43 +00:00
# Sync built-in extensions
node build/lib/builtInExtensions.js
2015-11-26 09:07:11 +00:00
# Build
test -d out || ./node_modules/.bin/gulp compile
2015-11-26 09:07:11 +00:00
2015-11-26 08:29:43 +00:00
# Configuration
export NODE_ENV=development
export VSCODE_DEV=1
export VSCODE_CLI=1
2015-11-26 08:29:43 +00:00
export ELECTRON_ENABLE_LOGGING=1
export ELECTRON_ENABLE_STACK_DUMPING=1
# Launch Code
exec "$CODE" . "$@"
2015-11-26 08:29:43 +00:00
}
2017-04-11 14:05:21 +00:00
# Use the following to get v8 tracing:
# code --js-flags="--trace-hydrogen --trace-phase=Z --trace-deopt --code-comments --hydrogen-track-positions --redirect-code-traces" "$@"
code "$@"