Module: Jets::AppLoader

Extended by:
AppLoader
Included in:
AppLoader
Defined in:
lib/jets/app_loader.rb

Overview

:nodoc:

Constant Summary collapse

RUBY =
Gem.ruby
EXECUTABLES =
["bin/jets", "script/jets"]
BUNDLER_WARNING =
"Beginning in Jets 5, Jets ships with a `jets` binstub at ./bin/jets that\nshould be used instead of the Bundler-generated `jets` binstub.\n\nIf you are seeing this message, your binstub at ./bin/jets was generated by\nBundler instead of Jets.\n\nYou might need to regenerate your `jets` binstub locally and add it to source\ncontrol:\n\n jets app:update:bin           # Bear in mind this generates other binstubs\n                               # too that you may or may not want (like yarn)\n\nIf you already have Jets binstubs in source control, you might be\ninadvertently overwriting them during deployment by using bundle install\nwith the --binstubs option.\n\nIf your application was created prior to Jets 4, here's how to upgrade:\n\n  bundle config --delete bin    # Turn off Bundler's stub generator\n  jets app:update:bin          # Use the new Jets executables\n  git add bin                   # Add bin/ to source control\n\nYou may need to remove bin/ from your .gitignore as well.\n\nWhen you install a gem whose executable you want to use in your app,\ngenerate it and add it to source control:\n\n  bundle binstubs some-gem-name\n  git add bin/new-executable\n\n"

Instance Method Summary collapse

Instance Method Details

#exec_appObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/jets/app_loader.rb', line 45

def exec_app
  original_cwd = Dir.pwd

  loop do
    if exe = find_executable
      contents = File.read(exe)

      if /(APP|ENGINE)_PATH/.match?(contents)
        exec RUBY, exe, *ARGV
        break # non reachable, hack to be able to stub exec in the test suite
      elsif exe.end_with?("bin/jets") && contents.include?("This file was generated by Bundler")
        $stderr.puts(BUNDLER_WARNING)
        Object.const_set(:APP_PATH, File.expand_path("config/application", Dir.pwd))
        # Do not run Jets.boot here else -e option is not respected. IE: jets console -e production
        require "jets/commands"
        break
      end
    end

    # If we exhaust the search there is no executable, this could be a
    # call to generate a new application, so restore the original cwd.
    Dir.chdir(original_cwd) && return if Pathname.new(Dir.pwd).root?

    # Otherwise keep moving upwards in search of an executable.
    Dir.chdir("..")
  end
end

#find_executableObject



73
74
75
# File 'lib/jets/app_loader.rb', line 73

def find_executable
  EXECUTABLES.find { |exe| File.file?(exe) }
end