module Utils::YarnWrapper

Public Instance Methods

run_yarn(command, *args) click to toggle source
# File lib/utils/yarn_wrapper.rb, line 5
    def run_yarn(command, *args)
      sh_command = <<~SH
        cd #{gem_path} && yarn #{Shellwords.escape(command)} #{prepare_args(args)}
      SH
      system(sh_command)
    end
validate_yarn_installation() click to toggle source
# File lib/utils/yarn_wrapper.rb, line 12
def validate_yarn_installation
  raise 'Yarn not installed!' if which_yarn_output.empty?
end

Private Instance Methods

gem_path() click to toggle source
# File lib/utils/yarn_wrapper.rb, line 18
def gem_path
  @gem_path ||=
    Shellwords.escape(Gem.loaded_specs['puppet_pdf'].full_gem_path)
end
prepare_args(args) click to toggle source
# File lib/utils/yarn_wrapper.rb, line 27
def prepare_args(args)
  args.map { |arg| Shellwords.escape(arg) }.join(' ')
end
which_yarn_output() click to toggle source
# File lib/utils/yarn_wrapper.rb, line 23
def which_yarn_output
  `which yarn`
end