2021-02-09 00:33:14 -05:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'pathname'
|
|
|
|
|
|
|
|
RAILS_ROOT = File.expand_path("../../", Pathname.new(__FILE__).realpath)
|
2021-04-29 14:13:36 -04:00
|
|
|
PORT = ENV["UNICORN_PORT"] ||= "3000"
|
2021-02-09 00:33:14 -05:00
|
|
|
|
2021-05-07 12:58:57 -04:00
|
|
|
yarn_dir = File.join(RAILS_ROOT, "app/assets/javascripts/discourse")
|
2021-02-09 00:33:14 -05:00
|
|
|
|
|
|
|
PROXY =
|
|
|
|
if ARGV.include?("--try")
|
|
|
|
"https://try.discourse.org"
|
|
|
|
else
|
|
|
|
"http://localhost:#{PORT}"
|
|
|
|
end
|
|
|
|
|
2021-05-10 09:34:24 -04:00
|
|
|
command =
|
|
|
|
if ARGV.include?("--test")
|
|
|
|
"test"
|
|
|
|
else
|
|
|
|
"server"
|
|
|
|
end
|
|
|
|
|
|
|
|
class String
|
|
|
|
def cyan
|
|
|
|
"\e[36m#{self}\e[0m"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-09 00:33:14 -05:00
|
|
|
if ARGV.include?("-h") || ARGV.include?("--help")
|
|
|
|
puts "ember-cli OPTIONS"
|
2021-05-10 09:34:24 -04:00
|
|
|
puts "#{"--try".cyan} To proxy try.discourse.org", ""
|
|
|
|
puts "#{"--test".cyan} To run the test suite", ""
|
2021-02-09 00:33:14 -05:00
|
|
|
puts "The rest of the arguments are passed to ember server per:", ""
|
2021-05-10 09:34:24 -04:00
|
|
|
exec "yarn --cwd #{yarn_dir} run ember #{command} --help"
|
2021-02-09 00:33:14 -05:00
|
|
|
end
|
|
|
|
|
2021-05-10 13:39:54 -04:00
|
|
|
args = ["--cwd", yarn_dir, "run", "ember", command] + ARGV.reject { |a| a == "--try" || a == "--test" }
|
2021-02-09 00:33:14 -05:00
|
|
|
|
|
|
|
if !args.include?("--proxy")
|
|
|
|
args << "--proxy"
|
|
|
|
args << PROXY
|
|
|
|
end
|
|
|
|
|
|
|
|
exec "yarn", *args.to_a.flatten
|