2016-02-18 13:47:09 +08:00
|
|
|
#!/usr/bin/env bash
|
2015-11-13 21:39:38 +08:00
|
|
|
|
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
|
|
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
|
2017-02-22 04:22:01 +08:00
|
|
|
ROOT=$(dirname "$(dirname "$(realpath "$0")")")
|
2015-11-13 21:39:38 +08:00
|
|
|
else
|
2017-02-22 04:22:01 +08:00
|
|
|
ROOT=$(dirname "$(dirname "$(readlink -f $0)")")
|
2015-11-13 21:39:38 +08:00
|
|
|
fi
|
|
|
|
|
2015-11-26 16:29:43 +08:00
|
|
|
function code() {
|
2017-02-22 04:22:01 +08:00
|
|
|
cd "$ROOT"
|
2015-11-13 21:39:38 +08:00
|
|
|
|
2016-08-09 23:13:08 +08:00
|
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
2016-08-09 23:56:05 +08:00
|
|
|
NAME=`node -p "require('./product.json').nameLong"`
|
2016-08-09 23:13:08 +08:00
|
|
|
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
|
|
|
|
else
|
|
|
|
NAME=`node -p "require('./product.json').applicationName"`
|
2016-08-09 23:57:09 +08:00
|
|
|
CODE=".build/electron/$NAME"
|
2016-08-09 23:13:08 +08:00
|
|
|
fi
|
|
|
|
|
2015-11-26 16:29:43 +08:00
|
|
|
# Node modules
|
2017-11-16 17:47:02 +08:00
|
|
|
test -d node_modules || yarn
|
2015-11-13 21:39:38 +08:00
|
|
|
|
2015-11-26 16:29:43 +08:00
|
|
|
# Get electron
|
2017-11-16 21:43:41 +08:00
|
|
|
node build/lib/electron.js || ./node_modules/.bin/gulp electron
|
2015-11-26 16:29:43 +08:00
|
|
|
|
2018-01-29 19:23:43 +08:00
|
|
|
# Sync built-in extensions
|
|
|
|
node build/lib/builtInExtensions.js
|
2018-01-23 23:40:41 +08:00
|
|
|
|
2015-11-26 17:07:11 +08:00
|
|
|
# Build
|
2016-03-04 03:49:26 +08:00
|
|
|
test -d out || ./node_modules/.bin/gulp compile
|
2015-11-26 17:07:11 +08:00
|
|
|
|
2015-11-26 16:29:43 +08:00
|
|
|
# Configuration
|
|
|
|
export NODE_ENV=development
|
|
|
|
export VSCODE_DEV=1
|
2016-08-08 22:12:32 +08:00
|
|
|
export VSCODE_CLI=1
|
2015-11-26 16:29:43 +08:00
|
|
|
export ELECTRON_ENABLE_LOGGING=1
|
|
|
|
export ELECTRON_ENABLE_STACK_DUMPING=1
|
|
|
|
|
|
|
|
# Launch Code
|
2016-08-09 23:13:08 +08:00
|
|
|
exec "$CODE" . "$@"
|
2015-11-26 16:29:43 +08:00
|
|
|
}
|
|
|
|
|
2017-04-11 22:05:21 +08: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" "$@"
|
|
|
|
|
2016-02-18 13:47:09 +08:00
|
|
|
code "$@"
|