Skip to content

Commit

Permalink
Merge pull request ManageIQ#17818 from himdel/assetpath-gem
Browse files Browse the repository at this point in the history
Vmdb::Plugins::AssetPath - add node_modules, development_gem?
  • Loading branch information
Fryguy authored Aug 10, 2018
2 parents 17a66ef + 34a016a commit 5871cb3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ tmp/*
# vendor/
vendor/bundle
vendor/assets/bower_components/
vendor/node_root/

# npm
node_modules/
Expand Down
23 changes: 20 additions & 3 deletions lib/vmdb/plugins/asset_path.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AssetPath
attr_reader :name
attr_reader :path
attr_reader :namespace
attr_reader :node_modules

def self.asset_path(engine)
engine.root.join('app', 'javascript')
Expand All @@ -20,9 +21,25 @@ def initialize(engine)
asset_path = self.class.asset_path(engine)
raise "#{asset_path} does not exist" unless asset_path.directory?

@name = engine.name
@path = engine.root
@namespace = name.chomp("::Engine").underscore.tr("/", "-")
@name = engine.name
@path = engine.root
@namespace = name.chomp("::Engine").underscore.tr("/", "-")
@in_bundler_gems = engine.root.expand_path.to_s.start_with?(Bundler.install_path.expand_path.to_s)

@node_modules = if @in_bundler_gems
self.class.node_root.join(@namespace)
else
@path
end.join('node_modules')
end

def development_gem?
!@in_bundler_gems
end

# also used in update:ui task to determine where to copy config files
def self.node_root
Rails.root.join('vendor', 'node_root')
end
end
end
Expand Down

0 comments on commit 5871cb3

Please sign in to comment.