honeylisp/vendor/lite-plugins/plugins/lastproject.lua
Jeremy Penner cb5132f393 git subrepo clone https://github.com/rxi/lite-plugins vendor/lite-plugins
subrepo:
  subdir:   "vendor/lite-plugins"
  merged:   "de4227d"
upstream:
  origin:   "https://github.com/rxi/lite-plugins"
  branch:   "master"
  commit:   "de4227d"
git-subrepo:
  version:  "0.4.2"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "65fde50"
2020-11-19 21:04:39 -05:00

27 lines
610 B
Lua

local core = require "core"
local last_project_filename = EXEDIR .. PATHSEP .. ".lite_last_project"
-- load last project path
local fp = io.open(last_project_filename)
local project_path
if fp then
project_path = fp:read("*a")
fp:close()
end
-- save current project path
local fp = io.open(last_project_filename, "w")
fp:write(system.absolute_path ".")
fp:close()
-- restart using last project path if we had no commandline arguments and could
-- find a last-project file
if #ARGS == 1 and project_path then
system.exec(string.format("%s %q", EXEFILE, project_path))
core.quit(true)
end