Skip to content

Commit 71433f3

Browse files
aduh95danielleadams
authored andcommitted
tools: refactor dynamic strings creation in shell scripts
PR-URL: #45240 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
1 parent f08c129 commit 71433f3

5 files changed

+39
-39
lines changed

tools/license-builder.sh

+30-30
Original file line numberDiff line numberDiff line change
@@ -30,91 +30,91 @@ fi
3030

3131

3232
# Dependencies bundled in distributions
33-
licenseText="$(cat "${rootdir}"/deps/acorn/acorn/LICENSE)"
33+
licenseText="$(cat "${rootdir}/deps/acorn/acorn/LICENSE")"
3434
addlicense "Acorn" "deps/acorn" "$licenseText"
35-
licenseText="$(tail -n +3 "${rootdir}"/deps/cares/LICENSE.md)"
35+
licenseText="$(tail -n +3 "${rootdir}/deps/cares/LICENSE.md")"
3636
addlicense "c-ares" "deps/cares" "$licenseText"
37-
licenseText="$(cat "${rootdir}"/deps/cjs-module-lexer/LICENSE)"
37+
licenseText="$(cat "${rootdir}/deps/cjs-module-lexer/LICENSE")"
3838
addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$licenseText"
3939
if [ -f "${rootdir}/deps/icu/LICENSE" ]; then
4040
# ICU 57 and following. Drop the BOM
41-
licenseText="$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu/LICENSE)"
41+
licenseText="$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}/deps/icu/LICENSE")"
4242
addlicense "ICU" "deps/icu" "$licenseText"
4343
elif [ -f "${rootdir}/deps/icu/license.html" ]; then
4444
# ICU 56 and prior
45-
licenseText="$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu/license.html)"
45+
licenseText="$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}/deps/icu/license.html")"
4646
addlicense "ICU" "deps/icu" "$licenseText"
4747
elif [ -f "${rootdir}/deps/icu-small/LICENSE" ]; then
4848
# ICU 57 and following. Drop the BOM
49-
licenseText="$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu-small/LICENSE)"
49+
licenseText="$(sed -e '1s/^[^a-zA-Z ]*ICU/ICU/' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}/deps/icu-small/LICENSE")"
5050
addlicense "ICU" "deps/icu-small" "$licenseText"
5151
elif [ -f "${rootdir}/deps/icu-small/license.html" ]; then
5252
# ICU 56 and prior
53-
licenseText="$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}"/deps/icu-small/license.html)"
53+
licenseText="$(sed -e '1,/ICU License - ICU 1\.8\.1 and later/d' -e :a -e 's/<[^>]*>//g;s/ / /g;s/ +$//;/</N;//ba' "${rootdir}/deps/icu-small/license.html")"
5454
addlicense "ICU" "deps/icu-small" "$licenseText"
5555
else
5656
echo "Could not find an ICU license file."
5757
exit 1
5858
fi
5959

60-
licenseText="$(cat "${rootdir}"/deps/uv/LICENSE)"
60+
licenseText="$(cat "${rootdir}/deps/uv/LICENSE")"
6161
addlicense "libuv" "deps/uv" "$licenseText"
6262
licenseText="$(cat deps/llhttp/LICENSE-MIT)"
6363
addlicense "llhttp" "deps/llhttp" "$licenseText"
64-
licenseText="$(cat "${rootdir}"/deps/corepack/LICENSE.md)"
64+
licenseText="$(cat "${rootdir}/deps/corepack/LICENSE.md")"
6565
addlicense "corepack" "deps/corepack" "$licenseText"
66-
licenseText="$(cat "${rootdir}"/deps/undici/LICENSE)"
66+
licenseText="$(cat "${rootdir}/deps/undici/LICENSE")"
6767
addlicense "undici" "deps/undici" "$licenseText"
68-
licenseText="$(cat "${rootdir}"/deps/openssl/openssl/LICENSE.txt)"
68+
licenseText="$(cat "${rootdir}/deps/openssl/openssl/LICENSE.txt")"
6969
addlicense "OpenSSL" "deps/openssl" "$licenseText"
7070
licenseText="$(curl -sL https://raw.githubusercontent.com/bestiejs/punycode.js/HEAD/LICENSE-MIT.txt)"
7171
addlicense "Punycode.js" "lib/punycode.js" "$licenseText"
72-
licenseText="$(cat "${rootdir}"/deps/v8/LICENSE)"
72+
licenseText="$(cat "${rootdir}/deps/v8/LICENSE")"
7373
addlicense "V8" "deps/v8" "$licenseText"
7474
licenseText="$(sed -e '/You should have received a copy of the CC0/,$d' -e 's/^\/\* *//' -e 's/^ \* *//' deps/v8/src/third_party/siphash/halfsiphash.cc)"
7575
addlicense "SipHash" "deps/v8/src/third_party/siphash" "$licenseText"
76-
licenseText="$(sed -e '/The data format used by the zlib library/,$d' -e 's/^\/\* *//' -e 's/^ *//' "${rootdir}"/deps/zlib/zlib.h)"
76+
licenseText="$(sed -e '/The data format used by the zlib library/,$d' -e 's/^\/\* *//' -e 's/^ *//' "${rootdir}/deps/zlib/zlib.h")"
7777
addlicense "zlib" "deps/zlib" "$licenseText"
7878

7979
# npm
80-
licenseText="$(cat "${rootdir}"/deps/npm/LICENSE)"
80+
licenseText="$(cat "${rootdir}/deps/npm/LICENSE")"
8181
addlicense "npm" "deps/npm" "$licenseText"
8282

8383
# Build tools
84-
licenseText="$(cat "${rootdir}"/tools/gyp/LICENSE)"
84+
licenseText="$(cat "${rootdir}/tools/gyp/LICENSE")"
8585
addlicense "GYP" "tools/gyp" "$licenseText"
86-
licenseText="$(cat "${rootdir}"/tools/inspector_protocol/LICENSE)"
86+
licenseText="$(cat "${rootdir}/tools/inspector_protocol/LICENSE")"
8787
addlicense "inspector_protocol" "tools/inspector_protocol" "$licenseText"
88-
licenseText="$(cat "${rootdir}"/tools/inspector_protocol/jinja2/LICENSE)"
88+
licenseText="$(cat "${rootdir}/tools/inspector_protocol/jinja2/LICENSE")"
8989
addlicense "jinja2" "tools/inspector_protocol/jinja2" "$licenseText"
90-
licenseText="$(cat "${rootdir}"/tools/inspector_protocol/markupsafe/LICENSE)"
90+
licenseText="$(cat "${rootdir}/tools/inspector_protocol/markupsafe/LICENSE")"
9191
addlicense "markupsafe" "tools/inspector_protocol/markupsafe" "$licenseText"
9292

9393
# Testing tools
94-
licenseText="$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' "${rootdir}"/tools/cpplint.py | tail -n +3)"
94+
licenseText="$(sed -e '/^$/,$d' -e 's/^#$//' -e 's/^# //' "${rootdir}/tools/cpplint.py" | tail -n +3)"
9595
addlicense "cpplint.py" "tools/cpplint.py" "$licenseText"
96-
licenseText="$(cat "${rootdir}"/tools/node_modules/eslint/LICENSE)"
96+
licenseText="$(cat "${rootdir}/tools/node_modules/eslint/LICENSE")"
9797
addlicense "ESLint" "tools/node_modules/eslint" "$licenseText"
98-
licenseText="$(cat "${rootdir}"/deps/googletest/LICENSE)"
98+
licenseText="$(cat "${rootdir}/deps/googletest/LICENSE")"
9999
addlicense "gtest" "deps/googletest" "$licenseText"
100100

101101
# nghttp2
102-
licenseText="$(cat "${rootdir}"/deps/nghttp2/COPYING)"
102+
licenseText="$(cat "${rootdir}/deps/nghttp2/COPYING")"
103103
addlicense "nghttp2" "deps/nghttp2" "$licenseText"
104104

105105
# large_pages
106-
licenseText="$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}"/src/large_pages/node_large_page.h)"
106+
licenseText="$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}/src/large_pages/node_large_page.h")"
107107
addlicense "large_pages" "src/large_pages" "$licenseText"
108108

109109
# deep_freeze
110-
licenseText="$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}"/lib/internal/freeze_intrinsics.js)"
110+
licenseText="$(sed -e '/SPDX-License-Identifier/,$d' -e 's/^\/\///' "${rootdir}/lib/internal/freeze_intrinsics.js")"
111111
addlicense "caja" "lib/internal/freeze_intrinsics.js" "$licenseText"
112112

113113
# brotli
114-
licenseText="$(cat "${rootdir}"/deps/brotli/LICENSE)"
114+
licenseText="$(cat "${rootdir}/deps/brotli/LICENSE")"
115115
addlicense "brotli" "deps/brotli" "$licenseText"
116116

117-
licenseText="$(cat "${rootdir}"/deps/histogram/LICENSE.txt)"
117+
licenseText="$(cat "${rootdir}/deps/histogram/LICENSE.txt")"
118118
addlicense "HdrHistogram" "deps/histogram" "$licenseText"
119119

120120
licenseText="$(curl -sL https://raw.githubusercontent.com/highlightjs/highlight.js/63f367c46f2eeb6f9b7a3545e325eeeb917f9942/LICENSE)"
@@ -126,16 +126,16 @@ addlicense "node-heapdump" "src/heap_utils.cc" "$licenseText"
126126
licenseText="$(curl -sL https://raw.githubusercontent.com/isaacs/rimraf/0e365ac4e4d64a25aa2a3cc026348f13410210e1/LICENSE)"
127127
addlicense "rimraf" "lib/internal/fs/rimraf.js" "$licenseText"
128128

129-
licenseText="$(cat "${rootdir}"/deps/uvwasi/LICENSE)"
129+
licenseText="$(cat "${rootdir}/deps/uvwasi/LICENSE")"
130130
addlicense "uvwasi" "deps/uvwasi" "$licenseText"
131-
licenseText="$(cat "${rootdir}"/deps/ngtcp2/LICENSE_ngtcp2)"
131+
licenseText="$(cat "${rootdir}/deps/ngtcp2/LICENSE_ngtcp2")"
132132
addlicense "ngtcp2" "deps/ngtcp2/ngtcp2/" "$licenseText"
133-
licenseText="$(cat "${rootdir}"/deps/ngtcp2/LICENSE_nghttp3)"
133+
licenseText="$(cat "${rootdir}/deps/ngtcp2/LICENSE_nghttp3")"
134134
addlicense "nghttp3" "deps/ngtcp2/nghttp3/" "$licenseText"
135135

136136
licenseText="$(curl -sL https://raw.githubusercontent.com/jprichardson/node-fs-extra/b34da2762a4865b025cac06d02d6a2f1f1027b65/LICENSE)"
137137
addlicense "node-fs-extra" "lib/internal/fs/cp" "$licenseText"
138138

139-
addlicense "base64" "deps/base64/base64/" "$(cat "${rootdir}"/deps/base64/base64/LICENSE)"
139+
addlicense "base64" "deps/base64/base64/" "$(cat "${rootdir}/deps/base64/base64/LICENSE" || true)"
140140

141141
mv "$tmplicense" "$licensefile"

tools/update-cares.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -e
33
# Shell script to update c-ares in the source tree to a specific version
44

5-
BASE_DIR="$( pwd )"/
6-
DEPS_DIR="$BASE_DIR"deps/
5+
BASE_DIR="$( pwd )"
6+
DEPS_DIR="$BASE_DIR/deps"
77
ARES_VERSION=$1
88

99
if [ "$#" -le 0 ]; then

tools/update-llhttp.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -e
33

44
# Shell script to update llhttp in the source tree to specific version
55

6-
BASE_DIR="$( pwd )"/
7-
DEPS_DIR="${BASE_DIR}deps/"
6+
BASE_DIR="$( pwd )"
7+
DEPS_DIR="${BASE_DIR}/deps"
88
LLHTTP_VERSION="$1"
99

1010
if [ "$#" -le 0 ]; then

tools/update-nghttp2.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -e
33
# Shell script to update nghttp2 in the source tree to specific version
44

5-
BASE_DIR="$( pwd )"/
6-
DEPS_DIR="$BASE_DIR"deps/
5+
BASE_DIR="$( pwd )"
6+
DEPS_DIR="$BASE_DIR/deps"
77
NGHTTP2_VERSION=$1
88

99
if [ "$#" -le 0 ]; then

tools/update-npm.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
set -e
33
# Shell script to update npm in the source tree to a specific version
44

5-
BASE_DIR="$( pwd )"/
6-
DEPS_DIR="$BASE_DIR"deps/
5+
BASE_DIR="$( pwd )"
6+
DEPS_DIR="$BASE_DIR/deps"
77
NPM_VERSION=$1
88

99
if [ "$#" -le 0 ]; then
@@ -40,7 +40,7 @@ rm -rf npm/
4040

4141
echo "Copying new npm"
4242

43-
tar zxf "$WORKSPACE"/cli/release/npm-"$NPM_VERSION".tgz
43+
tar zxf "$WORKSPACE/cli/release/npm-$NPM_VERSION.tgz"
4444

4545
echo ""
4646
echo "All done!"

0 commit comments

Comments
 (0)