Compare commits
2 Commits
a19f79b53a
...
v1.0
Author | SHA1 | Date | |
---|---|---|---|
80de336bdb | |||
be22f54635 |
@ -22,9 +22,6 @@ plugins = { -- the plugins you want to load
|
|||||||
file = 'eatit.lua', -- required, specifies the desired file
|
file = 'eatit.lua', -- required, specifies the desired file
|
||||||
dir = 'scripts', -- optional, sets the dest dir
|
dir = 'scripts', -- optional, sets the dest dir
|
||||||
branch = 'master', -- optional, sets the desired branch
|
branch = 'master', -- optional, sets the desired branch
|
||||||
cfg = function() -- optional, runs code on mpv startup
|
|
||||||
print('this is an example')
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
38
eatit.lua
38
eatit.lua
@ -114,6 +114,17 @@ local function startinstall()
|
|||||||
plugins[i]['dir'] = '~~/'
|
plugins[i]['dir'] = '~~/'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- get the plugins tmp download dir
|
||||||
|
local plugdir = opts.dl.dir .. '/' ..
|
||||||
|
string.match(plugins[i][1], '/([^/]+)$'):gsub('.git', '')
|
||||||
|
|
||||||
|
-- if no specified branch we use the default
|
||||||
|
if not plugins[i]['branch'] then
|
||||||
|
plugins[i]['branch'] = testforslash(
|
||||||
|
run('git -C ' .. plugdir .. ' symbolic-ref refs/remotes/origin/HEAD')
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
-- get the file's dir
|
-- get the file's dir
|
||||||
local pluginfile = opts.dl.dir .. '/' ..
|
local pluginfile = opts.dl.dir .. '/' ..
|
||||||
string.match(plugins[i][1], '/([^/]+)$'):gsub('.git', '') ..
|
string.match(plugins[i][1], '/([^/]+)$'):gsub('.git', '') ..
|
||||||
@ -122,18 +133,20 @@ local function startinstall()
|
|||||||
-- get the dest dir
|
-- get the dest dir
|
||||||
local destfile = mp.command_native({'expand-path', '~~/'}) ..
|
local destfile = mp.command_native({'expand-path', '~~/'}) ..
|
||||||
'/' .. plugins[i]['dir'] ..
|
'/' .. plugins[i]['dir'] ..
|
||||||
'/' .. plugins[i]['file']
|
'/' .. testforslash(plugins[i]['file'])
|
||||||
|
|
||||||
if fileexists(pluginfile) then
|
if fileexists(plugdir .. '/') then
|
||||||
-- if we need to update, update
|
-- if we need to update, update
|
||||||
if checkupdates(i) then
|
if checkupdates(plugdir) then
|
||||||
logwrite(plugins[i]['file'] .. ' is updating.')
|
logwrite(plugins[i]['file'] .. ' is updating.')
|
||||||
clonegit(i)
|
-- make sure we are on the main branch
|
||||||
|
run('git -C ' .. plugdir .. ' checkout -q ' .. plugins[i]['branch'])
|
||||||
|
run('git -C ' .. plugdir .. ' pull') -- get the latest commits
|
||||||
else
|
else
|
||||||
logwrite(plugins[i]['file'] .. ' is up to date!')
|
logwrite(plugins[i]['file'] .. ' is up to date!')
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
clonegit(i)
|
clonegit(plugdir, i)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- copy the file contents over to the desired location
|
-- copy the file contents over to the desired location
|
||||||
@ -161,20 +174,6 @@ local function initupdate()
|
|||||||
closelog()
|
closelog()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- run any user defined configs at startup
|
|
||||||
-- NOTE: This is kinda useless and might be removed if there is no way to make
|
|
||||||
-- it run in the desired plugin's thread
|
|
||||||
local function runopts()
|
|
||||||
openlog()
|
|
||||||
for i = 1, tablelength(plugins) do
|
|
||||||
if plugins[i]['cfg'] then
|
|
||||||
logwrite('Running ' .. plugins[i]['file'] .. '\'s config')
|
|
||||||
plugins[i]['cfg']()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
closelog()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- remove logfile on startup
|
-- remove logfile on startup
|
||||||
if opts.logging.log then
|
if opts.logging.log then
|
||||||
openlog()
|
openlog()
|
||||||
@ -182,5 +181,4 @@ if opts.logging.log then
|
|||||||
closelog()
|
closelog()
|
||||||
end
|
end
|
||||||
|
|
||||||
runopts()
|
|
||||||
mp.add_key_binding(opts.bind, 'UpdatePlugins', initupdate)
|
mp.add_key_binding(opts.bind, 'UpdatePlugins', initupdate)
|
||||||
|
Reference in New Issue
Block a user