Class: Shakapacker::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/shakapacker/compiler.rb

Constant Summary collapse

DOCTOR_HINT_MUTEX =
Mutex.new

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(instance) ⇒ Compiler

Returns a new instance of Compiler.



23
24
25
# File 'lib/shakapacker/compiler.rb', line 23

def initialize(instance)
  @instance = instance
end

Class Attribute Details

.doctor_hint_shownObject

Returns the value of attribute doctor_hint_shown.



17
18
19
# File 'lib/shakapacker/compiler.rb', line 17

def doctor_hint_shown
  @doctor_hint_shown
end

Instance Method Details

#compileObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/shakapacker/compiler.rb', line 27

def compile
  unless stale?
    logger.debug "Everything's up-to-date. Nothing to do"
    return true
  end

  if compiling?
    wait_for_compilation_to_complete
    true
  else
    acquire_ipc_lock do
      run_precompile_hook if should_run_precompile_hook?
      run_webpack.tap do |success|
        after_compile_hook
      end
    end
  end
end