-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab.bit.init
More file actions
52 lines (42 loc) · 1.61 KB
/
Copy pathgitlab.bit.init
File metadata and controls
52 lines (42 loc) · 1.61 KB
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
#!/bin/bash
# Check if $BIT_CONFIG_ACCESS_TOKEN is set
if [[ -z "$BIT_CONFIG_USER_TOKEN" && -z "$BIT_CONFIG_ACCESS_TOKEN" ]]; then
echo "Error: BIT_CONFIG_ACCESS_TOKEN environment variable is not set. It is required!"
exit 1
fi
# Assign BIT_CONFIG_ACCESS_TOKEN to BIT_CONFIG_USER_TOKEN
if [[ -z "$BIT_CONFIG_USER_TOKEN" ]]; then
BIT_CONFIG_USER_TOKEN="$BIT_CONFIG_ACCESS_TOKEN"
export BIT_CONFIG_USER_TOKEN
fi
# Extract the "engine" version
engine_version=$(grep '"engine":' workspace.jsonc | awk -F'"' '{print $4}')
# Check for "engineStrict": true
engine_strict=$(grep '"engineStrict": true' workspace.jsonc)
# If the engine_version exists and is not empty and engineStrict is true
if [[ ! -z "$engine_version" && ! -z "$engine_strict" ]]; then
echo "Engine version found: $engine_version with strict mode enabled"
bvm install "$engine_version"
fi
# Extract the defaultScope value from workspace.jsonc
defaultScope=$(grep -oP '"defaultScope": "\K[^"]+' workspace.jsonc)
# Split the defaultScope value into ORG and SCOPE using '.' as a delimiter
ORG=$(echo $defaultScope | cut -d'.' -f1)
SCOPE=$(echo $defaultScope | cut -d'.' -f2)
# Export ORG and SCOPE values
export ORG
export SCOPE
# Save ORG and SCOPE values to a temp file to share across scripts
echo "ORG=$ORG" > /tmp/ws.env
echo "SCOPE=$SCOPE" >> /tmp/ws.env
# Check if --skip-install is passed as an argument
if [[ " $@ " == *"--skip-install"* ]]; then
echo "Skipping bit install"
else
# Check if DEBUG is set and append --log to bit install if it is
if [[ -n "$DEBUG" ]]; then
bit install --log
else
bit install
fi
fi