forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pnpm-install.sh
executable file
·57 lines (44 loc) · 1.64 KB
/
pnpm-install.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
#!/bin/bash -e
if git diff --name-only HEAD^1 | grep -q -E 'types/(react|prop-types|scheduler)/'; then
echo "types/react and dependents will be installed; skipping hack"
pnpm install
exit 0
fi
if git diff --diff-filter=DR --name-only HEAD^1 | grep -q 'package.json'; then
echo "a package.json was removed; installing everything so dtslint-runner can run packages which now depend on npm instead"
pnpm install
exit 0
fi
# Workaround for https://github.com/pnpm/pnpm/issues/7283
# After installing everything the first time, reread the graph and see if anything was missing..
# If something was missing, we install that again and repeat until nothing is missing.
echo pnpm install --filter . --filter ...[HEAD^1]...
pnpm install --filter . --filter ...[HEAD^1]...
FILTERS=('--filter' '...@types/**[HEAD^1]...')
while true; do
OLD_FILTERS=("${FILTERS[@]}")
FILTERS=()
set +e
OUTPUT=$(pnpm ls --depth Infinity --parseable "${OLD_FILTERS[@]}")
CODE=$?
set -e
if [ $CODE -ne 0 ]; then
echo "pnpm ls failed while looking for missing deps; giving up and installing everything"
echo "$OUTPUT"
exec pnpm install
fi
for i in $(echo "$OUTPUT" | grep -v node_modules | awk NF | sort -u); do
i=${i#*$PWD/}
if [ -d "$i/node_modules" ]; then
continue
fi
echo "$i is a transitive dep that resolves to the workspace and must be manually installed"
FILTERS+=("--filter")
FILTERS+=("{./$i}...")
done
if [ ${#FILTERS[@]} -eq 0 ]; then
break
fi
echo pnpm install "${FILTERS[@]}"
pnpm install "${FILTERS[@]}"
done