# HG changeset patch # User Matthew Wild # Date 1451592075 0 # Node ID f39aceada1adb991493c3e1da139fa460a9a72a1 # Parent 2322f7932064ac00077e2233c79d1791357b09c5 squish.lua: Move opening of output file until after resolving modules diff -r 2322f7932064 -r f39aceada1ad squish.lua --- 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