7
7
8
8
set -ex
9
9
10
- cd " $( dirname " $0 " ) /.." || exit
10
+ ROOT=$( cd " $( dirname " $0 " ) /../.." && pwd)
11
+ [ -z " $NODE " ] && NODE=" $ROOT /out/Release/node"
12
+ [ -x " $NODE " ] || NODE=$( command -v node)
13
+ NPM=" $ROOT /deps/npm/bin/npm-cli.js"
14
+
15
+ NEW_VERSION=$( " $NODE " " $NPM " view undici dist-tags.latest)
16
+ CURRENT_VERSION=$( " $NODE " -p " require('./deps/undici/src/package.json').version" )
17
+
18
+ echo " Comparing $NEW_VERSION with $CURRENT_VERSION "
19
+
20
+ if [ " $NEW_VERSION " = " $CURRENT_VERSION " ]; then
21
+ echo " Skipped because Undici is on the latest version."
22
+ exit 0
23
+ fi
24
+
25
+ cd " $( dirname " $0 " ) /../.." || exit
11
26
rm -rf deps/undici/src
12
27
rm -f deps/undici/undici.js
13
28
@@ -16,25 +31,18 @@ rm -f deps/undici/undici.js
16
31
mkdir undici-tmp
17
32
cd undici-tmp || exit
18
33
19
- ROOT=" $PWD /.."
20
- [ -z " $NODE " ] && NODE=" $ROOT /out/Release/node"
21
- [ -x " $NODE " ] || NODE=$( command -v node)
22
- NPM=" $ROOT /deps/npm/bin/npm-cli.js"
23
-
24
34
" $NODE " " $NPM " init --yes
25
35
26
36
" $NODE " " $NPM " install --global-style --no-bin-links --ignore-scripts undici
27
37
cd node_modules/undici
28
38
" $NODE " " $NPM " run build:node
29
- # get the new version of undici
30
- UNDICI_VERSION=$( " $NODE " -p " require('./package.json').version" )
31
39
# update this version information in src/undici_version.h
32
40
FILE_PATH=" $ROOT /src/undici_version.h"
33
41
echo " // This is an auto generated file, please do not edit." > " $FILE_PATH "
34
42
echo " // Refer to tools/update-undici.sh" >> " $FILE_PATH "
35
43
echo " #ifndef SRC_UNDICI_VERSION_H_" >> " $FILE_PATH "
36
44
echo " #define SRC_UNDICI_VERSION_H_" >> " $FILE_PATH "
37
- echo " #define UNDICI_VERSION \" $UNDICI_VERSION \" " >> " $FILE_PATH "
45
+ echo " #define UNDICI_VERSION \" $NEW_VERSION \" " >> " $FILE_PATH "
38
46
echo " #endif // SRC_UNDICI_VERSION_H_" >> " $FILE_PATH "
39
47
)
40
48
@@ -43,3 +51,7 @@ mv deps/undici/src/undici-fetch.js deps/undici/undici.js
43
51
cp deps/undici/src/LICENSE deps/undici/LICENSE
44
52
45
53
rm -rf undici-tmp/
54
+
55
+ # The last line of the script should always print the new version,
56
+ # as we need to add it to $GITHUB_ENV variable.
57
+ echo " NEW_VERSION=$NEW_VERSION "
0 commit comments