1010--=
1111--============================================================]]
1212
13+ io.stdout :setvbuf (" no" )
14+ io.stderr :setvbuf (" no" )
15+
1316
1417
1518-- Parse arguments.
@@ -21,7 +24,7 @@ local command = args[i] or error("[arg] Missing command.")
2124i = i + 1
2225
2326_G .ignoreModificationTimes = false
24- _G .autobuild = false
27+ _G .autobuild = false
2528
2629---- ------------------------------------------------------------
2730
@@ -176,10 +179,10 @@ elseif command == "build" then
176179 local arg = args [i ]
177180
178181 if arg == " --force" or arg == " -f" then
179- ignoreModificationTimes = true
182+ _G . ignoreModificationTimes = true
180183
181184 elseif arg == " --autobuild" or arg == " -a" then
182- autobuild = true
185+ _G . autobuild = true
183186
184187 elseif arg == " --drafts" or arg == " -d" then
185188 includeDrafts = true
243246-- ==============================================================
244247
245248scriptEnvironmentGlobals = {
246- _WEBGEN_VERSION = _WEBGEN_VERSION ,
249+ _WEBGEN_VERSION = WEBGEN_VERSION ,
247250 DATA_FILE_EXTENSIONS = DATA_FILE_EXTENSIONS ,
248251 IMAGE_EXTENSIONS = IMAGE_EXTENSIONS ,
249252
@@ -302,7 +305,7 @@ scriptEnvironmentGlobals = {
302305
303306 -- Lua libraries.
304307 lfs = lfs ,
305- socket = socket ,
308+ socket = socket , -- May be nil.
306309
307310 -- Site objects. (Create at site generation.)
308311 site = nil ,
@@ -844,7 +847,7 @@ scriptEnvironment = setmetatable({}, {
844847-- ==============================================================
845848
846849local function buildWebsite ()
847- local startTime = socket . gettime ()
850+ local startTime = getTimeBetter ()
848851
849852 oncePrints = {}
850853 resetSiteVariables ()
@@ -961,7 +964,7 @@ local function buildWebsite()
961964 end
962965
963966 -- Validate config.baseUrl
964- local parsedUrl = socket . url .parse (site .baseUrl .v )
967+ local parsedUrl = require " url" .parse (site .baseUrl .v )
965968
966969 if site .baseUrl .v == " " then
967970 errorf (" config.baseUrl is missing or empty." , site .baseUrl .v )
@@ -1233,7 +1236,7 @@ local function buildWebsite()
12331236 logprint (" Error: Context stack is not empty after generation. (Depth is %d)" , # contextStack )
12341237 end
12351238
1236- local endTime = socket . gettime ()
1239+ local endTime = getTimeBetter ()
12371240
12381241 printf ((" -" ):rep (64 ))
12391242 printf (" Files: %d" , outputFileCount )
@@ -1260,7 +1263,7 @@ if autobuild then
12601263 local lastDirTree = nil
12611264
12621265 while true do
1263- socket . sleep (AUTOBUILD_MIN_INTERVAL )
1266+ sleep (AUTOBUILD_MIN_INTERVAL )
12641267
12651268 local dirTree = {}
12661269 local somethingChanged = false
0 commit comments