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.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
Instance Method Summary collapse
-
#initialize(script, config) ⇒ Process
constructor
A new instance of Process.
- #start ⇒ Object
- #stop ⇒ Object
- #valid? ⇒ Boolean
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 |
# File 'lib/webpack_driver/process.rb', line 18 def initialize(script, config) self.reset! @config = config args = ["./node_modules/.bin/#{script}"] + config.flags @proc = ::ChildProcess.build(*args) @proc.environment.merge!( config.environment ) puts "ENV" p config.environment @proc.cwd = config.directory 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.
16 17 18 |
# File 'lib/webpack_driver/process.rb', line 16 def config @config end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
15 16 17 |
# File 'lib/webpack_driver/process.rb', line 15 def @messages end |
Instance Method Details
#start ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/webpack_driver/process.rb', line 33 def start self.reset! @output, w = IO.pipe @proc.io.stdout = @proc.io.stderr = w @proc.start w.close @listener = listen_for_status_updates end |
#stop ⇒ Object
42 43 44 45 46 |
# File 'lib/webpack_driver/process.rb', line 42 def stop @proc.stop @output.close unless @output.closed? @listener.join end |
#valid? ⇒ Boolean
48 49 50 |
# File 'lib/webpack_driver/process.rb', line 48 def valid? ['operation'] == 'emit' end |