summarylogtreecommitdiffstats
path: root/rebuild-modules.sh
blob: f87cba64429a0608b2cfcce34bb18ee0ddbea913 (plain)
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
#! /bin/bash

set -e

if [ -z "$NW_PACKAGE_DIR" ]; then
    echo -e "\e[1;31m\$NW_PACKAGE_DIR is empty\e[0m" >&2
    exit 1
fi

if [ -z "$NW_VERSION" ]; then
    echo -e "\e[1;31m\$NW_VERSION is empty\e[0m" >&2
    exit 1
fi

TEMP_DIR=$(mktemp -d)
trap "{ rm -rf $TEMP_DIR; }" EXIT

# prepare python2
# fix https://github.com/nwjs/nw-gyp/issues/122
ln -sf "$(which python2)" "$TEMP_DIR/python"
export PATH=$TEMP_DIR:$PATH

node_modules="$NW_PACKAGE_DIR/node_modules"
dry_run="n"

if [ ! -d "$node_modules" ]; then
    echo -e "\e[1;31m$node_modules is not exist\e[0m" >&2
    exit 1
fi

for mod in "$node_modules"/*; do
    mod_name=$(basename "$mod")
    echo -e "\e[1;34mrebuild $mod_name\e[0m" >&2
    cd "${mod}"

    case "$mod_name" in
    spdlog-node|oniguruma-node|native-keymap|native-watchdog|extract-file-icon|node-pty-node)
        [ "$dry_run" = 'y' ] && continue
        npm install
        ;;
    spdlog|oniguruma|node-pty)
        [ "$dry_run" = 'y' ] && continue
        nw-gyp rebuild --target="${NW_VERSION}"
        ;;
    nodegit)
        [ "$dry_run" = 'y' ] && continue
        mkdir lib
        npm install
        npm run recompile
        ;;
    vscode-ripgrep)
        [ "$dry_run" = 'y' ] && continue
        rm -rf bin
        npm install
        ;;
    vscode-windows-*|windows-*)
        [ "$dry_run" = 'y' ] && continue
        cd "$node_modules"
        rm -rf "${mod}"
        ;;
    trash|vscode-oniguruma)
        [ "$dry_run" = 'y' ] && continue
        ;;
    *)
        echo -e "\e[1;31mcannot rebuild $mod\e[0m" >&2
        exit 1
        ;;
    esac
done