Class: Pod::Command::Demo

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods-dongjia/command/demo.rb

Instance Method Summary collapse

Instance Method Details

#runObject



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
# File 'lib/cocoapods-dongjia/command/demo.rb', line 15

def run

  dir = Dir.new('.')

  is_pod_root = false
  has_demo = false
  dir.each do |name|
    if name.end_with?('podspec') || name.end_with?('podspec.json')
      is_pod_root = true
    end
    if name == 'Demo'
      has_demo = true
    end
  end

  if is_pod_root
    if has_demo
      Pod::UI.warn('已存在 Demo')
    else
      `git clone [email protected]:ios-team/AppSpecDemo.git Demo`
      `rm -fr ./Demo/.git` if File.exist?('./Demo/.git')
    end
  else 
    Pod::UI.warn('当前不在一个 Pod 的根目录')
  end

end