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