1- local NODEJS_UTILS = {}
1+ local UTIL = {}
22
3- NODEJS_UTILS .NodeBaseUrl = " https://nodejs.org/dist/v%s/"
4- NODEJS_UTILS .FileName = " node-v%s-%s-%s%s"
5- NODEJS_UTILS .npmDownloadUrl = " https://github.com/npm/cli/archive/v%s.%s"
6- NODEJS_UTILS .VersionSourceUrl = " https://nodejs.org/dist/index.json"
3+ UTIL .NodeBaseUrl = " /v%s/"
4+ UTIL .FileName = " node-v%s-%s-%s%s"
5+ UTIL .VersionSourceUrl = " /index.json"
76
8- function NODEJS_UTILS .compare_versions (v1o , v2o )
7+ function UTIL .getBaseUrl ()
8+ local mirror = os.getenv (" VFOX_NODEJS_MIRROR" )
9+ if mirror == " " or mirror == nil then
10+ return " https://nodejs.org/dist"
11+ end
12+ return mirror
13+ end
14+
15+
16+
17+ function UTIL .compare_versions (v1o , v2o )
918 local v1 = v1o .version
1019 local v2 = v2o .version
1120 local v1_parts = {}
@@ -32,7 +41,7 @@ function NODEJS_UTILS.compare_versions(v1o, v2o)
3241end
3342
3443
35- function NODEJS_UTILS .get_checksum (file_content , file_name )
44+ function UTIL .get_checksum (file_content , file_name )
3645 for line in string.gmatch (file_content , ' ([^\n ]*)\n ?' ) do
3746 local checksum , name = string.match (line , ' (%w+)%s+(%S+)' )
3847 if name == file_name then
@@ -42,21 +51,21 @@ function NODEJS_UTILS.get_checksum(file_content, file_name)
4251 return nil
4352end
4453
45- function NODEJS_UTILS .is_semver_simple (str )
54+ function UTIL .is_semver_simple (str )
4655 -- match pattern: three digits, separated by dot
4756 local pattern = " ^%d+%.%d+%.%d+$"
4857 return str :match (pattern ) ~= nil
4958end
5059
5160
52- function NODEJS_UTILS .extract_semver (semver )
61+ function UTIL .extract_semver (semver )
5362 local pattern = " ^(%d+)%.(%d+)%.[%d.]+$"
5463 local major , minor = semver :match (pattern )
5564 return major , minor
5665end
5766
5867
59- function NODEJS_UTILS .calculate_shorthand (list )
68+ function UTIL .calculate_shorthand (list )
6069 local versions_shorthand = {}
6170 for _ , v in ipairs (list ) do
6271 local version = v .version
@@ -87,4 +96,4 @@ function NODEJS_UTILS.calculate_shorthand(list)
8796 return versions_shorthand
8897end
8998
90- return NODEJS_UTILS
99+ return UTIL
0 commit comments