Class: EmberCli::Shell
- Inherits:
-
Object
- Object
- EmberCli::Shell
- Defined in:
- lib/ember_cli/shell.rb
Instance Method Summary collapse
- #build_and_watch ⇒ Object
- #compile ⇒ Object
- #dev_server_running? ⇒ Boolean
-
#initialize(paths:, env: {}, options: {}) ⇒ Shell
constructor
A new instance of Shell.
- #install ⇒ Object
- #start_dev_server(host:, port:) ⇒ Object
- #stop ⇒ Object
- #test ⇒ Object
Constructor Details
#initialize(paths:, env: {}, options: {}) ⇒ Shell
Returns a new instance of Shell.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ember_cli/shell.rb', line 6 def initialize(paths:, env: {}, options: {}) @paths = paths @env = env @ember = Command.new( paths: paths, options: , ) @on_exit ||= at_exit { stop } end |
Instance Method Details
#build_and_watch ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ember_cli/shell.rb', line 20 def build_and_watch unless running? lock_buildfile self.pid = spawn( ember.build(watch: true), err: paths.build_error_file.to_s, ) detach end end |
#compile ⇒ Object
16 17 18 |
# File 'lib/ember_cli/shell.rb', line 16 def compile run! ember.build end |
#dev_server_running? ⇒ Boolean
47 48 49 |
# File 'lib/ember_cli/shell.rb', line 47 def dev_server_running? process_running?(dev_server_pid) end |
#install ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ember_cli/shell.rb', line 63 def install if paths.gemfile.exist? run! "#{paths.bundler} install" end if invalid_ember_dependencies? clean_ember_dependencies! end if paths.yarn run! "#{paths.yarn} install" else run! "#{paths.npm} prune && #{paths.npm} install" end if paths.bower_json.exist? run! "#{paths.bower} prune && #{paths.bower} install" end end |
#start_dev_server(host:, port:) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ember_cli/shell.rb', line 31 def start_dev_server(host:, port:) unless dev_server_running? # Run the development server in its own process group so that the # whole tree can be signaled when Rails exits. self.dev_server_pid = spawn( ember.dev_server(host: host, port: port), out: [paths.log.to_s, "a"], err: [:child, :out], pgroup: true, ) Process.detach(dev_server_pid) end dev_server_pid end |
#stop ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ember_cli/shell.rb', line 51 def stop if pid.present? signal(pid) self.pid = nil end if dev_server_pid.present? signal(-dev_server_pid) self.dev_server_pid = nil end end |
#test ⇒ Object
83 84 85 |
# File 'lib/ember_cli/shell.rb', line 83 def test run ember.test end |