Class: Rbpacker::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/rbpacker/cli.rb,
sig/rbpacker/cli.rbs

Overview

Command-line interface for rbpacker

Instance Method Summary collapse

Instance Method Details

#perform(src_file:, dst_file:, minify:)

This method returns an undefined value.

Parameters:

  • src_file: (String)
  • dst_file: (String, nil)

    non-nil: output to filepath, nil: output to stdout

  • minify: (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rbpacker/cli.rb', line 11

def perform(src_file:, dst_file:, minify:)
  content = SourceBundler.new.bundle(src_file).result

  content = Minifyrb::Minifier.new(content).minify if minify

  if dst_file
    File.binwrite(dst_file, content)
    warn "#{dst_file} is created"
  else
    $stdout.write(content)
  end
end