22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/opal-webpack-loader/load_path_manager.rb', line 22
def self.create_load_paths_cache
load_paths = if File.exist?(File.join('bin', 'rails'))
%x{
bundle exec rails runner "puts (Rails.configuration.respond_to?(:assets) ? (Rails.configuration.assets.paths + Opal.paths).uniq : Opal.paths)"
}
else
%x{
bundle exec ruby -e 'if File.exist?("app_loader.rb"); require "./app_loader.rb"; else; require "bundler/setup"; Bundler.require; set :run, false if defined? Sinatra; end; puts Opal.paths'
}
end
if $? == 0
load_path_lines = load_paths.split("\n")
load_path_lines.pop if load_path_lines.last == ''
load_path_entries = []
cwd = Dir.pwd
load_path_lines.each do |path|
next if path.start_with?(cwd)
more_path_entries = get_load_path_entries(path)
load_path_entries.push(*more_path_entries) if more_path_entries.size > 0
end
cache_obj = { 'opal_load_paths' => load_path_lines, 'opal_load_path_entries' => load_path_entries }
Dir.mkdir(OpalWebpackLoader::CompileServer::OWL_CACHE_DIR) unless Dir.exist?(OpalWebpackLoader::CompileServer::OWL_CACHE_DIR)
File.write(OpalWebpackLoader::CompileServer::OWL_LP_CACHE, Oj.dump(cache_obj, {}))
load_path_lines
else
raise 'Error getting load paths!'
exit(2)
end
end
|