11local lfs = require (" lfs" )
22local split
33split = require (" moonscript.util" ).split
4- local dirsep , dirsep_chars , mkdir , normalize_dir , parse_dir , parse_file , convert_path , iterate_path , format_time , gettime , compile_file_text , write_file , compile_and_write , is_abs_path , path_to_target
5- dirsep = package.config :sub (1 , 1 )
6- if dirsep == " \\ " then
7- dirsep_chars = " \\ /"
8- else
9- dirsep_chars = dirsep
4+ local dirsep , normalize_dir , normalize_path , parse_dir , parse_file , parse_subtree , convert_path
5+ do
6+ local _obj_0 = require (" moonscript.cmd.path_handling" )
7+ dirsep , normalize_dir , normalize_path , parse_dir , parse_file , parse_subtree , convert_path = _obj_0 .dirsep , _obj_0 .normalize_dir , _obj_0 .normalize_path , _obj_0 .parse_dir , _obj_0 .parse_file , _obj_0 .parse_subtree , _obj_0 .convert_path
108end
9+ local mkdir , format_time , gettime , compile_file_text , write_file , compile_and_write , path_to_target
1110mkdir = function (path )
1211 local chunks = split (path , dirsep )
1312 local accum
@@ -18,35 +17,6 @@ mkdir = function(path)
1817 end
1918 return lfs .attributes (path , " mode" )
2019end
21- normalize_dir = function (path )
22- local normalized_dir
23- if is_abs_path (path ) then
24- normalized_dir = dirsep
25- else
26- normalized_dir = " "
27- end
28- for path_element in iterate_path (path ) do
29- normalized_dir = normalized_dir .. (path_element .. dirsep )
30- end
31- return normalized_dir
32- end
33- end
34- parse_dir = function (path )
35- return (path :match (" ^(.-)[^" .. tostring (dirsep_chars ) .. " ]*$" ))
36- end
37- parse_file = function (path )
38- return (path :match (" ^.-([^" .. tostring (dirsep_chars ) .. " ]*)$" ))
39- end
40- convert_path = function (path )
41- local new_path = path :gsub (" %.moon$" , " .lua" )
42- if new_path == path then
43- new_path = path .. " .lua"
44- end
45- return new_path
46- end
47- iterate_path = function (path )
48- return path :gmatch (" ([^" .. tostring (dirsep_chars ) .. " ]+)" )
49- end
5020format_time = function (time )
5121 return (" %.3fms" ):format (time * 1000 )
5222end
@@ -161,14 +131,6 @@ compile_and_write = function(src, dest, opts)
161131 end
162132 return write_file (dest , code )
163133end
164- is_abs_path = function (path )
165- local first = path :sub (1 , 1 )
166- if dirsep == " \\ " then
167- return first == " /" or first == " \\ " or path :sub (2 , 1 ) == " :"
168- else
169- return first == dirsep
170- end
171- end
172134path_to_target = function (path , target_dir , base_dir )
173135 if target_dir == nil then
174136 target_dir = nil
@@ -198,14 +160,7 @@ path_to_target = function(path, target_dir, base_dir)
198160 return target
199161end
200162return {
201- dirsep = dirsep ,
202163 mkdir = mkdir ,
203- normalize_dir = normalize_dir ,
204- parse_dir = parse_dir ,
205- parse_file = parse_file ,
206- iterate_path = iterate_path ,
207- convert_path = convert_path ,
208- is_abs_path = is_abs_path ,
209164 gettime = gettime ,
210165 format_time = format_time ,
211166 path_to_target = path_to_target ,
0 commit comments