Skip to content

Commit fb9910b

Browse files
committed
Modify splat.moon to use :: instead of \ for chaining
1 parent be42c32 commit fb9910b

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

bin/splat.moon

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,43 @@
22
argparse = require "argparse"
33

44
parser = argparse "splat.moon", "Concatenate a collection of Lua modules into a single file"
5-
parser\option("--load -l", "Module names that will be load on require")\count "*"
5+
parser::option("--load -l", "Module names that will be load on require")::count "*"
66

7-
parser\argument("directories", "Directories to scan for Lua modules")\args "+"
7+
parser::argument("directories", "Directories to scan for Lua modules")::args "+"
88

9-
args = parser\parse [v for _, v in ipairs _G.arg]
9+
args = parser::parse [v for _, v in ipairs _G.arg]
1010
dirs = args.directories
1111

1212
normalize = (path) ->
13-
path\match("(.-)/*$").."/"
13+
path::match("(.-)/*$").."/"
1414

1515
lfs = require "lfs"
1616
scan_directory = (root, patt, collected={}) ->
1717
root = normalize root
1818
for fname in lfs.dir root
19-
if not fname\match "^%."
19+
if not fname::match "^%."
2020
full_path = root..fname
2121

2222
if lfs.attributes(full_path, "mode") == "directory"
2323
scan_directory full_path, patt, collected
2424
else
25-
if full_path\match patt
25+
if full_path::match patt
2626
table.insert collected, full_path
2727

2828
collected
2929

3030
path_to_module_name = (path) ->
31-
(path\match("(.-)%.lua")\gsub("/", "."))
31+
(path::match("(.-)%.lua")::gsub("/", "."))
3232

3333
each_line = (text) ->
3434
coroutine.wrap ->
3535
start = 1
3636
while true
37-
pos, after = text\find "\n", start, true
37+
pos, after = text::find "\n", start, true
3838
break if not pos
39-
coroutine.yield text\sub start, pos - 1
39+
coroutine.yield text::sub start, pos - 1
4040
start = after + 1
41-
coroutine.yield text\sub start, #text
41+
coroutine.yield text::sub start, #text
4242
nil
4343

4444
write_module = (name, text) ->
@@ -52,19 +52,19 @@ for dir in *dirs
5252
files = scan_directory dir, "%.lua$"
5353
chunks = for path in *files
5454
module_name = path_to_module_name path
55-
content = io.open(path)\read"*a"
55+
content = io.open(path)::read"*a"
5656
modules[module_name] = true
5757
{module_name, content}
5858

5959
for chunk in *chunks
6060
name, content = unpack chunk
61-
base = name\match"(.-)%.init"
61+
base = name::match"(.-)%.init"
6262
if base and not modules[base] then
6363
modules[base] = true
6464
name = base
6565
write_module name, content
6666

6767
for module_name in *args.load
6868
if modules[module_name]
69-
print ([[package.preload["%s"]()]])\format module_name
69+
print ([[package.preload["%s"]()]])::format module_name
7070

0 commit comments

Comments
 (0)