Class: WebpackDriver::Process
- Inherits:
-
Object
- Object
- WebpackDriver::Process
- Extended by:
- Forwardable
- Defined in:
- lib/webpack_driver/process.rb
Constant Summary collapse
- READ_CHUNK_SIZE =
1024
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#last_compilation_message ⇒ Object
readonly
Returns the value of attribute last_compilation_message.
-
#last_status ⇒ Object
readonly
Returns the value of attribute last_status.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#progress ⇒ Object
readonly
Returns the value of attribute progress.
Instance Method Summary collapse
- #in_progress? ⇒ Boolean
-
#initialize(script, config) ⇒ Process
constructor
A new instance of Process.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(script, config) ⇒ Process
Returns a new instance of Process.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/webpack_driver/process.rb', line 18 def initialize(script, config) self.reset! @config = config args = ["./node_modules/.bin/#{script}"] + config.flags config.logger.info("Starting webpack using command:\n#{args.join(' ')}") @proc = ::ChildProcess.build(*args) @proc.environment.merge!( config.environment ) if config.directory config.logger.info("In directory: #{config.directory}") @proc.cwd = config.directory end end |
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def assets @assets end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def config @config end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def error @error end |
#last_compilation_message ⇒ Object (readonly)
Returns the value of attribute last_compilation_message.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def end |
#last_status ⇒ Object (readonly)
Returns the value of attribute last_status.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def last_status @last_status end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def end |
#progress ⇒ Object (readonly)
Returns the value of attribute progress.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def progress @progress end |
Instance Method Details
#in_progress? ⇒ Boolean
50 51 52 |
# File 'lib/webpack_driver/process.rb', line 50 def in_progress? !! ( !@error && @progress && @progress != 1 ) end |
#start ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/webpack_driver/process.rb', line 34 def start self.reset! @output, w = IO.pipe @proc.io.stdout = @proc.io.stderr = w @proc.start w.close @progress = 0.0 @listener = listen_for_status_updates end |
#stop ⇒ Object
44 45 46 47 48 |
# File 'lib/webpack_driver/process.rb', line 44 def stop @proc.stop @output.close unless @output.closed? @listener.join end |