Add Command#require_models!
This commit is contained in:
parent
dc0093c7d9
commit
c1b3498e99
5 changed files with 10 additions and 4 deletions
|
@ -16,4 +16,10 @@ class Twenty::Command < Cmd
|
|||
require_relative "command/disconnect"
|
||||
require_relative "command/migrate"
|
||||
require_relative "command/console"
|
||||
|
||||
private
|
||||
|
||||
def require_models!
|
||||
require "twenty/server/model"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,9 +21,9 @@ class Twenty::Command::Connect < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
require "twenty/server/model"
|
||||
path = File.realpath(options.path ? options.path : Dir.getwd)
|
||||
if File.exist?(path)
|
||||
require_models!
|
||||
project = Twenty::Project.create(
|
||||
name: File.basename(path),
|
||||
path:
|
||||
|
|
|
@ -24,7 +24,7 @@ class Twenty::Command::Console < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
require "twenty/server/model"
|
||||
require_models!
|
||||
require "irb"
|
||||
TOPLEVEL_BINDING.irb
|
||||
end
|
||||
|
|
|
@ -19,8 +19,8 @@ class Twenty::Command::Disconnect < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
require "twenty/server/model"
|
||||
path = File.realpath(options.path ? options.path : Dir.getwd)
|
||||
require_models!
|
||||
Twenty::Project
|
||||
.where(path:)
|
||||
.first!
|
||||
|
|
|
@ -36,7 +36,7 @@ class Twenty::Command::Up < Twenty::Command
|
|||
private
|
||||
|
||||
def run_command(options)
|
||||
require "twenty/server/model"
|
||||
require_models!
|
||||
File.binwrite(pid, Process.pid.to_s)
|
||||
thr = Twenty::Rack.server(options).start
|
||||
thr.join
|
||||
|
|
Loading…
Reference in a new issue