Sun, 06 Sep 2020 22:12:52 +0300
Don't auto-create directories that will be empty
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
1 | |
21
3c71c525cec2
Use markdown-it as default markdown parser.
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
2 | local lgen={} |
3c71c525cec2
Use markdown-it as default markdown parser.
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
3 | local lgen_path=string.gsub(arg[0], "(.*)/[^/]*", "%1"); |
3c71c525cec2
Use markdown-it as default markdown parser.
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
4 | if lgen_path~=nil then |
3c71c525cec2
Use markdown-it as default markdown parser.
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
5 | package.path=package.path .. ';' .. lgen_path .. '/?.lua' |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
6 | end |
2 | 7 | |
5 | 8 | -- Lua 5.1 setfenv/getfenv compatibility for Lua 5.2 |
9
751216807683
Further lua5.3 compatibility fixes
Tuomo Valkonen <tuomov@iki.fi>
parents:
7
diff
changeset
|
9 | -- This is required by the "obsolete" ltp module |
5 | 10 | local CE = require('compat_env') |
11 | _G.setfenv = CE.setfenv | |
12 | _G.getfenv = CE.getfenv | |
13 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
14 | local scan=require('scan') |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
15 | local handlers=require('handlers') |
3 | 16 | -- globally add missing stuff |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
17 | local luaext=require('luaext') |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
18 | local lfs=require('lfs') |
26
77cd7b8fb6a6
Rename path.lua mypath.lua not conflict with other lua path modules.
Tuomo Valkonen <tuomov@iki.fi>
parents:
21
diff
changeset
|
19 | local path=require('mypath') |
2 | 20 | |
21 | -- | |
22 | -- Main | |
23 | -- | |
24 | ||
3 | 25 | if #arg < 3 then |
26 | error("Usage: lgen src tmpl dst") | |
2 | 27 | end |
28 | ||
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
29 | local src = arg[1] |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
30 | local tmpl = arg[2] |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
31 | local dst = arg[3] |
2 | 32 | |
33 | print('Scan...') | |
7
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
34 | |
038275cd92ed
Convert module stuff to lua 5.3
Tuomo Valkonen <tuomov@iki.fi>
parents:
5
diff
changeset
|
35 | local hierarchy = scan.scan(src) |
2 | 36 | |
3 | 37 | |
38 | local env={ | |
39 | paths={ | |
40 | src=src, | |
41 | dst=dst, | |
42 | tmpl=tmpl, | |
21
3c71c525cec2
Use markdown-it as default markdown parser.
Tuomo Valkonen <tuomov@iki.fi>
parents:
9
diff
changeset
|
43 | lgen_location=lgen_path, |
3 | 44 | }, |
45 | pages={ | |
46 | }, | |
47 | } | |
48 | ||
49 | ||
2 | 50 | -- Pitäisi env konstruoida. polun perusteella. |
51 | scan.map(hierarchy, function(f) handlers.choose(f, env) end) | |
52 | ||
53 | print('Phase 1...') | |
54 | scan.map(hierarchy, function(f) handlers.phase1(f, env) end) | |
55 | print('Phase 2...') | |
3 | 56 | scan.map(hierarchy, function(f) handlers.phase2(f, env) end, |
57 | function(d) | |
58 | --log.log("Make path "..path.join(dst, d).."\n") | |
35
2f927eae429b
Don't auto-create directories that will be empty
Tuomo Valkonen <tuomov@iki.fi>
parents:
26
diff
changeset
|
59 | --lfs.mkdir(path.join(dst, d)) |
3 | 60 | end) |
61 | --print('Phase 3...') | |
62 | --scan.map(hierarchy, function(f) handlers.phase3(f, env) end) |