Class: Webpacker::Commands

Inherits:
Object
  • Object
show all
Defined in:
lib/webpacker/commands.rb

Instance Method Summary collapse

Constructor Details

#initialize(webpacker) ⇒ Commands

Returns a new instance of Commands.



4
5
6
# File 'lib/webpacker/commands.rb', line 4

def initialize(webpacker)
  @webpacker = webpacker
end

Instance Method Details

#bootstrapObject



24
25
26
# File 'lib/webpacker/commands.rb', line 24

def bootstrap
  manifest.refresh
end

#clean(count = 2) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/webpacker/commands.rb', line 8

def clean(count = 2)
  if config.public_output_path.exist? && config.public_manifest_path.exist? && versions.count > count
    versions.drop(count).flat_map(&:last).each do |file|
      File.delete(file) if File.file?(file)
      logger.info "Removed #{file}"
    end
  end

  true
end

#clobberObject



19
20
21
22
# File 'lib/webpacker/commands.rb', line 19

def clobber
  config.public_output_path.rmtree if config.public_output_path.exist?
  config.cache_path.rmtree if config.cache_path.exist?
end

#compileObject



28
29
30
31
32
# File 'lib/webpacker/commands.rb', line 28

def compile
  compiler.compile.tap do |success|
    manifest.refresh if success
  end
end