squish.lua: Move opening of output file until after resolving modules

Thu, 31 Dec 2015 20:01:15 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 31 Dec 2015 20:01:15 +0000
changeset 87
f39aceada1ad
parent 86
2322f7932064
child 88
60e10cf9b20c

squish.lua: Move opening of output file until after resolving modules

squish.lua file | annotate | diff | comparison | revisions
--- a/squish.lua	Tue Nov 27 08:25:18 2012 -0800
+++ b/squish.lua	Thu Dec 31 20:01:15 2015 +0000
@@ -152,21 +152,6 @@
 	end
 end
 
-print_info("Writing "..out_fn.."...");
-local f, err = io.open(out_fn, "w+");
-if not f then
-	print_err("Couldn't open output file: "..tostring(err));
-	os.exit(1);
-end
-
-if opts.executable then
-	if opts.executable == true then
-		f:write("#!/usr/bin/env lua\n");
-	else
-		f:write(opts.executable, "\n");
-	end
-end
-
 print_verbose("Resolving modules...");
 do
 	local LUA_DIRSEP = package.config:sub(1,1);
@@ -211,6 +196,20 @@
 	end
 end
 
+print_info("Writing "..out_fn.."...");
+local f, err = io.open(out_fn, "w+");
+if not f then
+	print_err("Couldn't open output file: "..tostring(err));
+	os.exit(1);
+end
+
+if opts.executable then
+	if opts.executable == true then
+		f:write("#!/usr/bin/env lua\n");
+	else
+		f:write(opts.executable, "\n");
+	end
+end
 
 print_verbose("Packing modules...");
 for _, module in ipairs(modules) do

mercurial