-
Notifications
You must be signed in to change notification settings - Fork 0
/
vim.thor
66 lines (57 loc) · 1.8 KB
/
vim.thor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
begin
require 'psych'
rescue LoadError
end
require 'yaml'
require 'pathname'
require 'rbconfig'
class Vim < Thor
include Thor::Actions
desc 'install', 'Installations des plugins'
def install
plugins.each_pair do |name, repo|
plugin_path = File.join('bundle', name)
unless File.exist? plugin_path
run "git submodule add #{repo} #{plugin_path}"
run "git config --file=.gitmodules submodule.#{plugin_path}.ignore dirty"
say "Installation de #{name}"
end
end
end
desc 'update', 'Mise a jours des plugins installes'
def update
plugins.each_pair do |name, repo|
plugin_path = File.join('bundle', name)
if File.exist? plugin_path
say "Mise a jours de #{name}"
Dir.chdir plugin_path do
run "git checkout master"
run "git pull"
end
end
end
end
desc 'clean', 'Nettoyage des plugins non references dans plugins.yml'
def clean
Pathname("bundle").each_child do |f|
next if "pathogen" == f.basename
if f.directory? && !plugins.has_key?(f.basename.to_s)
say "Suppression de #{name}"
begin
run "git config --remove-section submodule.'#{f}'"
run "git config --file=.gitmodules --remove-section submodule.'#{f}'"
run "git rm -r --cached '#{f}'"
f.rmtree
rescue
end
end
end
end
protected
def plugins
@plugins_yml ||= YAML.load_file 'plugins.yml'
end
def windows?
(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/) ? true : false
end
end