Skip to content

Commit d7ed1a8

Browse files
author
Akash Satheesan
committed
fix(npm-postinstall): change node version logic
1 parent e408c63 commit d7ed1a8

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ jobs:
271271
- name: Replace node with arm64 equivalent
272272
run: |
273273
wget https://nodejs.org/dist/v14.17.0/node-v14.17.0-linux-arm64.tar.xz
274-
tar -xzf node-v14.17.0-linux-arm64.tar.xz node-v14.17.0-linux-arm64/bin/node --strip-components=2
274+
tar -xf node-v14.17.0-linux-arm64.tar.xz node-v14.17.0-linux-arm64/bin/node --strip-components=2
275275
mv ./node ./release-standalone/lib/node
276276
277277
- name: Build packages with nfpm

ci/build/npm-postinstall.sh

+20-3
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,21 @@ main() {
2323
# Grabs the major version of node from $npm_config_user_agent which looks like
2424
# yarn/1.21.1 npm/? node/v14.2.0 darwin x64
2525
major_node_version=$(echo "$npm_config_user_agent" | sed -n 's/.*node\/v\([^.]*\).*/\1/p')
26-
if [ "$major_node_version" -lt 14 ]; then
27-
echo "code-server currently requires at least node v14"
26+
27+
if [ -n "$FORCE_NODE_VERSION" ]; then
28+
echo "WARNING: Overriding required Node.js version to v$FORCE_NODE_VERSION"
29+
echo "This could lead to broken functionality, and is unsupported."
30+
echo "USE AT YOUR OWN RISK!"
31+
fi
32+
33+
if [ "$major_node_version" -ne ${FORCE_NODE_VERSION:-14} ]; then
34+
echo "ERROR: code-server currently requires node v14."
35+
if [ -n "$FORCE_NODE_VERSION" ]; then
36+
echo "However, you have overrided the version check to use v$FORCE_NODE_VERSION."
37+
fi
2838
echo "We have detected that you are on node v$major_node_version"
29-
echo "See https://github.com/cdr/code-server/issues/1633"
39+
echo "You can override this version check by setting \$FORCE_NODE_VERSION,"
40+
echo "but configurations that do not use the same node version are unsupported."
3041
exit 1
3142
fi
3243

@@ -54,6 +65,12 @@ main() {
5465
echo "Please see https://github.com/cdr/code-server/blob/master/docs/npm.md"
5566
exit 1
5667
fi
68+
69+
if [ -n "$FORCE_NODE_VERSION" ]; then
70+
echo "WARNING: The required Node.js version was overriden to v$FORCE_NODE_VERSION"
71+
echo "This could lead to broken functionality, and is unsupported."
72+
echo "USE AT YOUR OWN RISK!"
73+
fi
5774
}
5875

5976
# This is a copy of symlink_asar in ../lib.sh. Look there for details.

0 commit comments

Comments
 (0)