class Opal::Sprockets::Processor
def process_required_trees(required_trees, context)
Internal: Add files required with `require_tree` as asset dependencies.
def process_required_trees(required_trees, context) return if required_trees.empty? # This is the root dir of the logical path, we need this because # the compiler gives us the path relative to the file's logical path. dirname = File.dirname(input[:filename]).gsub(/#{Regexp.escape File.dirname(context.logical_path)}#{Opal::REGEXP_END}/, '') dirname = Pathname(dirname) required_trees.each do |original_required_tree| required_tree = Pathname(original_required_tree) unless required_tree.relative? raise ArgumentError, "require_tree argument must be a relative path: #{required_tree.inspect}" end required_tree = dirname.join(input[:filename], '..', required_tree) unless required_tree.directory? raise ArgumentError, "require_tree argument must be a directory: #{{source: original_required_tree, pathname: required_tree}.inspect}" end context.depend_on required_tree.to_s environment = context.environment processor = ::Sprockets::DirectiveProcessor.new processor.instance_variable_set('@dirname', File.dirname(input[:filename])) processor.instance_variable_set('@environment', environment) path = processor.__send__(:expand_relative_dirname, :require_tree, original_required_tree) absolute_paths = environment.__send__(:stat_sorted_tree_with_dependencies, path).first.map(&:first) absolute_paths.each do |path| path = Pathname(path) pathname = path.relative_path_from(dirname).to_s pathname_noext = pathname.sub(sprockets_extnames_regexp, '') if path.to_s == logical_path then next elsif ::Opal::Config.stubbed_files.include?(pathname_noext) then next elsif path.directory? then context.depend_on(path.to_s) else context.require_asset(pathname_noext) end end end end