Method: Bake::Blocks::BlockBase#cleanProjectDir

Defined in:
lib/blocks/blockBase.rb

#cleanProjectDirObject



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/blocks/blockBase.rb', line 178

def cleanProjectDir
  if !Bake.options.filename
    Dir.chdir(@projectDir) do
      if File.exist?@block.output_dir
        puts "Deleting folder #{@block.output_dir}" if Bake.options.verbose >= 2
        if !Bake.options.dry
          FileUtils.rm_rf(@block.output_dir)
        end

        if (@block.tcs[:OUTPUT_DIR] == nil) && (Bake.options.buildDirDelimiter == "/") # in this case all builds are placed in a "build" folder
          buildDir = File.dirname(@block.output_dir)
          if (File.basename(buildDir) == "build") && (Dir.entries(buildDir).size == 2)# double check if it's really "build" and check if it's empty (except "." and "..")
            puts "Deleting folder #{buildDir}" if Bake.options.verbose >= 2
            if !Bake.options.dry
              FileUtils.rm_rf(buildDir)
            end
          end
        end

      end
    end
  end
  return true
end