Class: VsClean::Clean

Inherits:
CLAide::Command
  • Object
show all
Defined in:
lib/clean.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Clean

Returns a new instance of Clean.



12
13
14
# File 'lib/clean.rb', line 12

def initialize(argv)
  super
end

Instance Method Details

#delete(path) ⇒ Object



35
36
37
38
39
40
# File 'lib/clean.rb', line 35

def delete(path)
  FileUtils.rm_r(path)
  Console.log_substep("Deleted ./#{path}")
rescue StandardError => e
  Console.log_error("Could not delete './#{path}': #{e.message}")
end

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/clean.rb', line 16

def run
  # Delete bin and obj directories

  paths = Dir.glob("**/{bin,obj}").select { |f| File.directory?(f) }
  
  # Delete .suo files (can cause Intellisense errors, among other things)

  paths.push(*Dir.glob("**/.vs/**/.suo"))
  
  if paths.none?
    Console.log_step("All is well with the world... nothing to clean!")
    return
  end
    
  Console.log_step("Cleaning...") 
  
  paths.each { |d| delete(d) }
  
  Console.log_step("Done!")
end