diff options
| -rw-r--r-- | src/luarocks/core/util.tl | 9 | ||||
| -rw-r--r-- | src/luarocks/path.tl | 21 | ||||
| -rw-r--r-- | src/luarocks/util.tl | 33 |
3 files changed, 32 insertions, 31 deletions
diff --git a/src/luarocks/core/util.tl b/src/luarocks/core/util.tl index 30461566..e278ebf0 100644 --- a/src/luarocks/core/util.tl +++ b/src/luarocks/core/util.tl | |||
| @@ -117,6 +117,15 @@ function util.show_table(t: {any:any}, tname: string, top_indent: string): strin | |||
| 117 | return cart .. autoref | 117 | return cart .. autoref |
| 118 | end | 118 | end |
| 119 | 119 | ||
| 120 | --- Produce a Lua pattern that matches precisely the given string | ||
| 121 | -- (this is suitable to be concatenating to other patterns, | ||
| 122 | -- so it does not include beginning- and end-of-string markers (^$) | ||
| 123 | -- @param s string: The input string | ||
| 124 | -- @return string: The equivalent pattern | ||
| 125 | function util.matchquote(s: string): string | ||
| 126 | return (s:gsub("[?%-+*%[%].%%()$^]","%%%1")) | ||
| 127 | end | ||
| 128 | |||
| 120 | --- Merges contents of src on top of dst's contents | 129 | --- Merges contents of src on top of dst's contents |
| 121 | -- (i.e. if an key from src already exists in dst, replace it). | 130 | -- (i.e. if an key from src already exists in dst, replace it). |
| 122 | -- @param dst Destination table, which will receive src's contents. | 131 | -- @param dst Destination table, which will receive src's contents. |
diff --git a/src/luarocks/path.tl b/src/luarocks/path.tl index 93fb6aae..4bf2e47c 100644 --- a/src/luarocks/path.tl +++ b/src/luarocks/path.tl | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | local cfg = require("luarocks.core.cfg") | 6 | local cfg = require("luarocks.core.cfg") |
| 7 | local core = require("luarocks.core.path") | 7 | local core = require("luarocks.core.path") |
| 8 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
| 9 | -- local util = require("luarocks.util") --! crashes teal | 9 | local util = require("luarocks.core.util") |
| 10 | 10 | ||
| 11 | local type Tree = cfg.Tree | 11 | local type Tree = cfg.Tree |
| 12 | 12 | ||
| @@ -28,6 +28,14 @@ path.deploy_lib_dir = core.deploy_lib_dir | |||
| 28 | path.map_trees = core.map_trees | 28 | path.map_trees = core.map_trees |
| 29 | path.rocks_tree_to_string = core.rocks_tree_to_string | 29 | path.rocks_tree_to_string = core.rocks_tree_to_string |
| 30 | 30 | ||
| 31 | function path.root_dir(tree: string | Tree): string | ||
| 32 | if tree is string then | ||
| 33 | return tree | ||
| 34 | else | ||
| 35 | return tree.root | ||
| 36 | end | ||
| 37 | end | ||
| 38 | |||
| 31 | --- Infer rockspec filename from a rock filename. | 39 | --- Infer rockspec filename from a rock filename. |
| 32 | -- @param rock_name string: Pathname of a rock file. | 40 | -- @param rock_name string: Pathname of a rock file. |
| 33 | -- @return string: Filename of the rockspec, without path. | 41 | -- @return string: Filename of the rockspec, without path. |
| @@ -37,16 +45,7 @@ function path.rockspec_name_from_rock(rock_name: string): string | |||
| 37 | end | 45 | end |
| 38 | 46 | ||
| 39 | function path.root_from_rocks_dir(rocks_dir: string): string | 47 | function path.root_from_rocks_dir(rocks_dir: string): string |
| 40 | return "" --! temp | 48 | return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") |
| 41 | -- return rocks_dir:match("(.*)" .. util.matchquote(cfg.rocks_subdir) .. ".*$") --! only depends here on util | ||
| 42 | end | ||
| 43 | |||
| 44 | function path.root_dir(tree: string | Tree): string | ||
| 45 | if tree is string then | ||
| 46 | return tree | ||
| 47 | else | ||
| 48 | return tree.root | ||
| 49 | end | ||
| 50 | end | 49 | end |
| 51 | 50 | ||
| 52 | function path.deploy_bin_dir(tree: string | Tree): string | 51 | function path.deploy_bin_dir(tree: string | Tree): string |
diff --git a/src/luarocks/util.tl b/src/luarocks/util.tl index 77d6f5c4..aff245b8 100644 --- a/src/luarocks/util.tl +++ b/src/luarocks/util.tl | |||
| @@ -19,6 +19,7 @@ local record util | |||
| 19 | printerr: function(...: string | number) | 19 | printerr: function(...: string | number) |
| 20 | warning: function(string) | 20 | warning: function(string) |
| 21 | keys: function<K, V>({K : V}): {K} | 21 | keys: function<K, V>({K : V}): {K} |
| 22 | matchquote: function(string): string | ||
| 22 | 23 | ||
| 23 | record Fn | 24 | record Fn |
| 24 | fn: function(...: any) | 25 | fn: function(...: any) |
| @@ -63,16 +64,17 @@ local record util | |||
| 63 | end | 64 | end |
| 64 | end | 65 | end |
| 65 | 66 | ||
| 66 | -- util.cleanup_path = core.cleanup_path --tlcheck acting funny | 67 | util.cleanup_path = core.cleanup_path --tlcheck acting funny |
| 67 | -- util.split_string = core.split_string | 68 | util.split_string = core.split_string |
| 68 | -- util.sortedpairs = core.sortedpairs | 69 | util.sortedpairs = core.sortedpairs |
| 69 | -- util.deep_merge = core.deep_merge | 70 | util.deep_merge = core.deep_merge |
| 70 | -- util.deep_merge_under = core.deep_merge_under | 71 | util.deep_merge_under = core.deep_merge_under |
| 71 | -- util.popen_read = core.popen_read | 72 | util.popen_read = core.popen_read |
| 72 | -- util.show_table = core.show_table | 73 | util.show_table = core.show_table |
| 73 | -- util.printerr = core.printerr | 74 | util.printerr = core.printerr |
| 74 | -- util.warning = core.warning | 75 | util.warning = core.warning |
| 75 | -- util.keys = core.keys | 76 | util.keys = core.keys |
| 77 | util.matchquote = core.matchquote | ||
| 76 | 78 | ||
| 77 | local type Fn = util.Fn | 79 | local type Fn = util.Fn |
| 78 | local type Rockspec = util.Rockspec | 80 | local type Rockspec = util.Rockspec |
| @@ -122,15 +124,6 @@ function util.run_scheduled_functions() | |||
| 122 | end | 124 | end |
| 123 | end | 125 | end |
| 124 | 126 | ||
| 125 | --- Produce a Lua pattern that matches precisely the given string | ||
| 126 | -- (this is suitable to be concatenating to other patterns, | ||
| 127 | -- so it does not include beginning- and end-of-string markers (^$) | ||
| 128 | -- @param s string: The input string | ||
| 129 | -- @return string: The equivalent pattern | ||
| 130 | function util.matchquote(s: string): string | ||
| 131 | return (s:gsub("[?%-+*%[%].%%()$^]","%%%1")) | ||
| 132 | end | ||
| 133 | |||
| 134 | local var_format_pattern = "%$%((%a[%a%d_]+)%)" | 127 | local var_format_pattern = "%$%((%a[%a%d_]+)%)" |
| 135 | 128 | ||
| 136 | -- Check if a set of needed variables are referenced | 129 | -- Check if a set of needed variables are referenced |
| @@ -305,7 +298,7 @@ end | |||
| 305 | 298 | ||
| 306 | function util.announce_install(rockspec: Rockspec) | 299 | function util.announce_install(rockspec: Rockspec) |
| 307 | local cfg = require("luarocks.core.cfg") | 300 | local cfg = require("luarocks.core.cfg") |
| 308 | local path = require("luarocks.path") | 301 | local path = require("luarocks.core.path") --TEAL BUG? |
| 309 | 302 | ||
| 310 | local suffix = "" | 303 | local suffix = "" |
| 311 | if rockspec.description and rockspec.description.license then | 304 | if rockspec.description and rockspec.description.license then |
