Permalink
Browse files

Fixes #20312: Use bundler_ext in production for webpack plugin

  • Loading branch information...
1 parent f079f90 commit 85d8d1c0145385f6f34f6634a00fc0e60e8a77de @ehelms ehelms committed with dLobatog Jul 25, 2017
Showing with 32 additions and 3 deletions.
  1. +16 −3 script/plugin_webpack_directories.rb
  2. +16 −0 test/unit/script/plugin_webpack_directories_test.rb
@@ -1,15 +1,28 @@
#! /usr/bin/env ruby
-require 'bundler'
require 'json'
+if File.exist?(File.expand_path(File.join(%w[.. .. Gemfile.in]), __FILE__))
+ require 'bundler_ext'
+ gemfile_in = File.expand_path(File.join(%w[.. .. Gemfile.in]), __FILE__)
+ specs = BundlerExt::Gemfile.parse(gemfile_in, :all).map { |spec, value| value[:dep] }
+else
+ require 'bundler'
+ specs = Bundler.load.specs
+end
+
PLUGIN_NAME_REGEXP = /foreman*|katello*/
config = { entries: {}, paths: [] }
-Bundler.load.specs.each do |dep|
+specs.each do |dep|
# skip other rails engines that are not plugins
# TOOD: Consider using the plugin registeration api?
- next unless dep.name =~ PLUGIN_NAME_REGEXP
+ if gemfile_in
+ next unless dep =~ PLUGIN_NAME_REGEXP
+ dep = dep.to_spec
+ else
+ next unless dep.name =~ PLUGIN_NAME_REGEXP
+ end
path = "#{dep.to_spec.full_gem_path}/webpack"
entry = "#{path}/index.js"
# some plugings share the same base directory (tasks-core and tasks, REX etc)
@@ -0,0 +1,16 @@
+require 'minitest/autorun'
+require 'json'
+
+class PluginWebpackDirectoriesTest < Minitest::Test
+ def setup
+ @root_dir = File.expand_path(File.join(%w[.. .. .. ..]), __FILE__)
+ @script = File.join(%W[#{@root_dir} script plugin_webpack_directories.rb])
+ end
+
+ def test_bundler
+ plugin_webpack = `#{@script}`
+
+ assert File.exist?(@script)
+ assert_equal JSON.parse(plugin_webpack).keys(), ['entries', 'paths']
+ end
+end

0 comments on commit 85d8d1c

Please sign in to comment.