MisterDA / love-release

:love_letter: Lua script that makes LÖVE game release easier
MIT License
451 stars 27 forks source link

love-release not packing everything in project directory #36

Closed videah closed 6 years ago

videah commented 8 years ago

For some reason, only my font folder, conf.lua, and my readme gets packed. Any reason this is happening?

MisterDA commented 8 years ago

I have stumbled upon this once too, but I wasn't able to identify the causes of this error. I'll try to fix this.

pablomayobre commented 8 years ago

Would you please check the return value of fs.pop_dir

I think it may stay in that directory for ever

Also changing the current directory like that inside the loop may destroy the iterator

Consider saving all the folder names and after the whole folder was iterated, iterate on the next one

These are just suggestions not tested and not proved to work, but some ideas that may help debug this. Cheers

MisterDA commented 8 years ago

fs.pop_dir returns true if a pop ocurred, false if the stack was empty.

Thanks for the suggestions :)

Debug all the things !

pablomayobre commented 7 years ago

Try something like this:

local _buildFileTree
_buildFileTree = function(dir)
  local subDirs = {}

  for file in assert(fs.dir()) do
    if not file:find("^%.git") then
      if fs.is_dir(file) then
        subDirs[#subDirs + 1] = file
      elseif fs.is_file(file) then
        dir[#dir+1] = file
      end
    end
  end

  for _, path in ipairs(subDirs) do
    local newDir = {}
    dir[path] = newDir
    assert(fs.change_dir(path))
    _buildFileTree(newDir)
    assert(fs.pop_dir())
  end
end

This has the overhead of needing a secondary loop but will probably work more reliably.

You have to consider that fs.dir returns an iterator based on a coroutine and Lua is not that good with coroutines, and handling multiple coroutines at once, switching between them and so on...

pablomayobre commented 7 years ago

This should be fixed now 👍