Class: Hanami::CLI::Commands::App::Assets::Command Private
- Inherits:
-
Command
- Object
- Dry::CLI::Command
- Hanami::CLI::Command
- Command
- Hanami::CLI::Commands::App::Assets::Command
- Defined in:
- lib/hanami/cli/commands/app/assets/command.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base class for assets commands.
Finds slices with assets present (anything in an assets/
dir), then forks a child
process for each slice to run the assets command (config/assets.js
) for the slice.
Prefers the slice's own config/assets.js
if present, otherwise falls back to the
app-level file.
Passes --path
and --dest
arguments to this command to compile assets for the given
slice only and save them into a dedicated directory (public/assets/
for the app,
public/[slice_name]/
for slices).
Constant Summary
Constants inherited from Command
Instance Method Summary collapse
- #call ⇒ Object private
-
#initialize(out:, err:, config: app.config.assets, system_call: InteractiveSystemCall.new(out: out, err: err, exit_after: false), **opts) ⇒ Command
constructor
private
A new instance of Command.
Methods inherited from Command
#app, #database, #database_config, inherited, #measure, #run_command
Methods inherited from Hanami::CLI::Command
Constructor Details
#initialize(out:, err:, config: app.config.assets, system_call: InteractiveSystemCall.new(out: out, err: err, exit_after: false), **opts) ⇒ Command
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Command.
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/hanami/cli/commands/app/assets/command.rb', line 32 def initialize( out:, err:, config: app.config.assets, system_call: InteractiveSystemCall.new(out: out, err: err, exit_after: false), **opts ) super(out: out, err: err, **opts) @config = config @system_call = system_call end |
Instance Method Details
#call ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hanami/cli/commands/app/assets/command.rb', line 46 def call(**) slices = slices_with_assets if slices.empty? out.puts "No assets found." return end slices.each do |slice| unless assets_config(slice) out.puts "No assets config found for #{slice}. Please create a config/assets.js." return end end pids = slices_with_assets.map { |slice| fork_child_assets_command(slice) } Signal.trap("INT") do pids.each do |pid| Process.kill("INT", pid) end end Process.waitall end |