Skip to content

Commit

Permalink
Don't add E2 tests to Wiremod's default data files
Browse files Browse the repository at this point in the history
These tests are for developers and so shouldn't be shipped to people
who just install the addon through the workshop.
  • Loading branch information
AbigailBuccaneer committed Sep 23, 2019
1 parent 2678c4c commit ff8ab0d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lua/wire/default_data_decompressor.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
-- Garry has imposed a file extension whitelist for the Steam Workshop which does not permit the dangerous format .txt
-- Therefore, we must store our .txt's in default_data_files.lua, and then extract them when first run

local ignored_dirs = {
["expression2/tests"] = true,
}

-- Compress all files in addons/wire/data recursively into 1 json string
local function ReadDir(root)
if ignored_dirs[root] then return nil end
local tab = {}
local files,dirs = file.Find("addons/wire/data/"..root.."*","GAME")
for _, f in pairs(files) do
Expand All @@ -16,7 +21,7 @@ local function ReadDir(root)
return tab
end
-- Uncomment and Rename this file to wire/lua/wire/default_data_files.lua to update it
//file.Write("default_data_files.txt", "//"..util.TableToJSON(ReadDir("")))
-- file.Write("default_data_files.txt", "//"..util.TableToJSON(ReadDir("")))

-- Decompress the json string wire/lua/wire/default_data_files.lua into the corresponding 36+ default data files
local function WriteDir(tab)
Expand All @@ -34,7 +39,7 @@ if not file.Exists("expression2/_helloworld_.txt", "DATA") then
local compressed = file.Read("wire/default_data_files.lua","LUA")
-- The client cannot read lua files sent by the server (for security?), so clientside this'll only work
-- if the client actually has Wiremod installed, though with workshop autodownload that'll be common
if compressed != nil then
if compressed ~= nil then
WriteDir(util.JSONToTable(string.sub(compressed, 3)))
end
end

0 comments on commit ff8ab0d

Please sign in to comment.