diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/util.tl | 2 | ||||
| -rw-r--r-- | src/luarocks/path.tl | 2 | ||||
| -rw-r--r-- | src/luarocks/util-original.lua (renamed from src/luarocks/util.lua) | 0 | ||||
| -rw-r--r-- | src/luarocks/util.tl | 24 |
4 files changed, 21 insertions, 7 deletions
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index e278ebf0..e9c21dac 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl | |||
| @@ -16,7 +16,7 @@ local type CompFn = util.CompFn | |||
| 16 | -- @param spec string: "*l" by default, to read a single line. | 16 | -- @param spec string: "*l" by default, to read a single line. |
| 17 | -- May be used to read more, passing, for instance, "*a". | 17 | -- May be used to read more, passing, for instance, "*a". |
| 18 | -- @return string: the output of the program. | 18 | -- @return string: the output of the program. |
| 19 | function util.popen_read(cmd: string, spec: string): string | 19 | function util.popen_read(cmd: string, spec?: string): string |
| 20 | local tmpfile: string = (dir_sep == "\\") | 20 | local tmpfile: string = (dir_sep == "\\") |
| 21 | and (os.getenv("TMP") .. "/luarocks-" .. tostring(math.floor(math.random() * 10000))) | 21 | and (os.getenv("TMP") .. "/luarocks-" .. tostring(math.floor(math.random() * 10000))) |
| 22 | or os.tmpname() | 22 | or os.tmpname() |
diff --git a/src/luarocks/path.tl b/src/luarocks/path.tl index 4bf2e47c..ffcf26c8 100644 --- a/src/luarocks/path.tl +++ b/src/luarocks/path.tl | |||
| @@ -171,7 +171,7 @@ end | |||
| 171 | -- @param file_name string: pathname of a rock or rockspec | 171 | -- @param file_name string: pathname of a rock or rockspec |
| 172 | -- @return (string, string, string) or nil: name, version and arch | 172 | -- @return (string, string, string) or nil: name, version and arch |
| 173 | -- or nil if name could not be parsed | 173 | -- or nil if name could not be parsed |
| 174 | function path.parse_name(file_name: string): string | 174 | function path.parse_name(file_name: string): string, string, string |
| 175 | if file_name:match("%.rock$") then | 175 | if file_name:match("%.rock$") then |
| 176 | return dir.base_name(file_name):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") | 176 | return dir.base_name(file_name):match("(.*)-([^-]+-%d+)%.([^.]+)%.rock$") |
| 177 | else | 177 | else |
diff --git a/src/luarocks/util.lua b/src/luarocks/util-original.lua index de9157fc..de9157fc 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util-original.lua | |||
diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index bc6ddecd..868e1552 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl | |||
| @@ -15,7 +15,7 @@ local record util | |||
| 15 | sortedpairs: function<K, V, S>({K : V}, CompFn | {K | {K, S}}): function(): K, V, S | 15 | sortedpairs: function<K, V, S>({K : V}, CompFn | {K | {K, S}}): function(): K, V, S |
| 16 | deep_merge: function({any : any}, {any : any}) | 16 | deep_merge: function({any : any}, {any : any}) |
| 17 | deep_merge_under: function({any : any}, {any : any}) | 17 | deep_merge_under: function({any : any}, {any : any}) |
| 18 | popen_read: function(string, string): string | 18 | popen_read: function(string, ?string): string |
| 19 | show_table: function({any : any}, string, string): string | 19 | show_table: function({any : any}, string, string): string |
| 20 | printerr: function(...: string | number) | 20 | printerr: function(...: string | number) |
| 21 | warning: function(string) | 21 | warning: function(string) |
| @@ -24,7 +24,7 @@ local record util | |||
| 24 | 24 | ||
| 25 | record Fn | 25 | record Fn |
| 26 | fn: function(...: any) | 26 | fn: function(...: any) |
| 27 | args: {any: any} | 27 | args: table.PackTable<any> |
| 28 | end | 28 | end |
| 29 | 29 | ||
| 30 | record Parser --? | 30 | record Parser --? |
| @@ -34,6 +34,7 @@ local record util | |||
| 34 | flag: function(Parser, string): Parser | 34 | flag: function(Parser, string): Parser |
| 35 | hidden: function(Parser, boolean): Parser | 35 | hidden: function(Parser, boolean): Parser |
| 36 | end | 36 | end |
| 37 | |||
| 37 | end | 38 | end |
| 38 | 39 | ||
| 39 | util.cleanup_path = core.cleanup_path --tlcheck acting funny | 40 | util.cleanup_path = core.cleanup_path --tlcheck acting funny |
| @@ -92,7 +93,7 @@ function util.run_scheduled_functions() | |||
| 92 | end | 93 | end |
| 93 | for i = #scheduled_functions, 1, -1 do | 94 | for i = #scheduled_functions, 1, -1 do |
| 94 | local item = scheduled_functions[i] | 95 | local item = scheduled_functions[i] |
| 95 | item.fn(table.unpack(item.args, 1, item.args.n)) --! here a list and onn line 52 we produse a record | 96 | item.fn(table.unpack(item.args, 1, item.args.n)) |
| 96 | end | 97 | end |
| 97 | end | 98 | end |
| 98 | 99 | ||
| @@ -148,7 +149,7 @@ function util.variable_substitutions(tbl: {string: string}, vars: {string: strin | |||
| 148 | 149 | ||
| 149 | local updated = {} | 150 | local updated = {} |
| 150 | for k, v in pairs(tbl) do | 151 | for k, v in pairs(tbl) do |
| 151 | if type(v) == "string" then | 152 | if v is string then |
| 152 | updated[k] = v:gsub(var_format_pattern, vars) | 153 | updated[k] = v:gsub(var_format_pattern, vars) |
| 153 | if warn_failed_matches(updated[k]) then | 154 | if warn_failed_matches(updated[k]) then |
| 154 | updated[k] = updated[k]:gsub(var_format_pattern, "") | 155 | updated[k] = updated[k]:gsub(var_format_pattern, "") |
| @@ -284,7 +285,7 @@ end | |||
| 284 | -- @param unnamed_paths table: An array of rockspec paths that don't contain rock | 285 | -- @param unnamed_paths table: An array of rockspec paths that don't contain rock |
| 285 | -- name and version in regular format. | 286 | -- name and version in regular format. |
| 286 | -- @param subdir string: path to subdirectory. | 287 | -- @param subdir string: path to subdirectory. |
| 287 | local function collect_rockspecs(versions: {string: vers.Version}, paths: {string: string}, unnamed_paths: {string}, subdir: string) --! fs stuff | 288 | local function collect_rockspecs(versions: {string: string}, paths: {string: string}, unnamed_paths: {string}, subdir: string) --! fs stuff |
| 288 | local fs = require("luarocks.fs") | 289 | local fs = require("luarocks.fs") |
| 289 | local dir = require("luarocks.dir") | 290 | local dir = require("luarocks.dir") |
| 290 | local path = require("luarocks.path") | 291 | local path = require("luarocks.path") |
| @@ -512,6 +513,19 @@ do | |||
| 512 | -- end | 513 | -- end |
| 513 | -- end | 514 | -- end |
| 514 | 515 | ||
| 516 | -- local function insert_lua_variants(names, luaver) | ||
| 517 | -- local variants = { | ||
| 518 | -- "lua" .. luaver .. exe_suffix, | ||
| 519 | -- "lua" .. luaver:gsub("%.", "") .. exe_suffix, | ||
| 520 | -- "lua-" .. luaver .. exe_suffix, | ||
| 521 | -- "lua-" .. luaver:gsub("%.", "") .. exe_suffix, | ||
| 522 | -- } | ||
| 523 | -- for _, name in ipairs(variants) do | ||
| 524 | -- names[name] = luaver | ||
| 525 | -- table.insert(names, name) | ||
| 526 | -- end | ||
| 527 | -- end | ||
| 528 | |||
| 515 | find_lua_bindir = function(prefix: string, luaver: string, verbose: string): string, string, string | 529 | find_lua_bindir = function(prefix: string, luaver: string, verbose: string): string, string, string |
| 516 | local names: HashArrayRecord = {} | 530 | local names: HashArrayRecord = {} |
| 517 | if luaver then | 531 | if luaver then |
