-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix.sh
executable file
·54 lines (41 loc) · 1.67 KB
/
fix.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
#!/bin/bash
# Let's fix your project!
printHelp () {
printf "\nThe Electron ABI fixer resolves module mismatch errors.\n\nUsage: sh electron-abi-fix.sh 49 1.3.4\n\nIn this example 49 is the target abi version and 1.3.4 is the Electron version. If you don't specify the Electron version, this script will try to determine it by your package.json.\n\n"
exit
}
if [ $# -eq 0 ]; then
printHelp
elif [ $# -gt 2 ]; then
printHelp
elif [ $# -eq 2 ]; then
electronVersion=$2
fi
abiVersion=$1
if ! command -v jq >/dev/null; then
echo "I couldn't find jq but I need it. Perhaps try 'apt-get install jq' or 'yum install jq' then run me again."
exit 2
fi
if [ ! -f "package.json" ]; then
echo "I don't see your package.json file. Perhaps you're in the wrong directory."
exit 1
fi
if [ $# < 2 ]; then
electronVersion=$(cat package.json | jq -r '.dependencies.electron')
if [ $electronVersion = "null" ]; then
electronVersion=$(cat package.json | jq -r '.devDependencies.electron')
fi
if [ $electronVersion = "null" ]; then
electronVersion=$(cat package.json | jq -r '.devDependencies.electron-prebuilt')
fi
if [ $electronVersion = "null" ]; then
electronVersion=$(cat package.json | jq -r '.dependencies.electron-prebuilt')
fi
if [ $electronVersion = "null" ]; then
echo "I couldn't find your electron version specified in package.json. Pass it to me if you need to like: electron-abi-fix.sh 49 1.3.4"
exit 1
fi
fi
printf "\n\nAttemping to fix module mismatch error...\n\n"
npm rebuild --runtime=electron --target=$electronVersion --disturl=https://atom.io/download/atom-shell --abi=$abiVersion
printf "\n\nHopefully now you can start your Electron app!\n\n"