forked from nylas/nylas-mail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
N1.sh
executable file
·103 lines (85 loc) · 2.38 KB
/
N1.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# This file is sym-linked to the `electron` executable.
# It is used by `apm` when calling commands.
if [ "$(uname)" == 'Darwin' ]; then
OS='Mac'
elif [ "$(expr substr $(uname -s) 1 5)" == 'Linux' ]; then
OS='Linux'
elif [ "$(expr substr $(uname -s) 1 10)" == 'MINGW32_NT' ]; then
OS='Cygwin'
else
echo "Your platform ($(uname -a)) is not supported."
exit 1
fi
while getopts ":wtfvh-:" opt; do
case "$opt" in
-)
case "${OPTARG}" in
wait)
WAIT=1
;;
help|version)
REDIRECT_STDERR=1
EXPECT_OUTPUT=1
;;
foreground|test)
EXPECT_OUTPUT=1
;;
esac
;;
w)
WAIT=1
;;
h|v)
REDIRECT_STDERR=1
EXPECT_OUTPUT=1
;;
f|t)
EXPECT_OUTPUT=1
;;
esac
done
if [ $REDIRECT_STDERR ]; then
exec 2> /dev/null
fi
N1_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd );
export N1_PATH
if [ $OS == 'Mac' ]; then
if [ -z "$N1_PATH" ]; then
echo "Set the N1_PATH environment variable to the absolute location of the main edgehill folder."
exit 1
fi
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron} # Set ELECTRON_PATH unless it is already set
# Exit if Electron can't be found
if [ ! -d "$ELECTRON_PATH" ]; then
echo "Cannot locate electron. Be sure you have run script/bootstrap first from $N1_PATH"
exit 1
fi
# We find the electron executable inside of the electron directory.
$ELECTRON_PATH/Electron.app/Contents/MacOS/Electron --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
elif [ $OS == 'Linux' ]; then
DOT_INBOX_DIR="$HOME/.nylas"
mkdir -p "$DOT_INBOX_DIR"
if [ -z "$N1_PATH" ]; then
echo "Set the N1_PATH environment variable to the absolute location of the main N1 folder."
exit 1
fi
ELECTRON_PATH=${ELECTRON_PATH:-$N1_PATH/electron} # Set ELECTRON_PATH unless it is already set
# Exit if Electron can't be found
if [ ! -d "$ELECTRON_PATH" ]; then
echo "Cannot locate electron. Be sure you have run script/bootstrap first from $N1_PATH"
exit 1
fi
# We find the electron executable inside of the electron directory.
$ELECTRON_PATH/electron --executed-from="$(pwd)" --pid=$$ "$@" $N1_PATH
fi
on_die() {
exit 0
}
trap 'on_die' SIGQUIT SIGTERM
# If the wait flag is set, don't exit this process until Electron tells it to.
if [ $WAIT ]; then
while true; do
sleep 1
done
fi