Sha256: 44ad84956a9f1a0254a339d1b1b125894bb44b6179961a8a875faa31c663cf43
Contents?: true
Size: 1.73 KB
Versions: 11
Compression:
Stored size: 1.73 KB
Contents
#!/usr/bin/env ruby # WANT_JSON # init bundler in dev env # HACK Keep track of the ENV vars we overwrite so we can swap them back in # later when we need to run the command. # $replaced_env_vars = {} if ENV['QB_DEV_ENV'] ENV.each {|k, v| if k.start_with? 'QB_DEV_ENV_' key = k.sub('QB_DEV_ENV_', '') $replaced_env_vars[key] = [ENV[key], v] ENV[key] = v end } require 'bundler/setup' end require 'qb' require 'cmds' using NRSER class Stream < QB::Ansible::Module def main template = @args['template'] || @args['cmd'] if template.nil? raise ArgumentError, "Must supply `template` or `cmd` argument." end if @args['creates'] && File.exists?( @args['creates'] ) debug "File #{ @args['creates'] } exists, skipping" return nil end opts = {} [:args, :kwds, :input, :assert, :env, :chdir].each { |key| opts[key] = @args[key.to_s] if @args.key?(key.to_s) } [:format, :env_mode].each { |key| opts[key] = @args[key.to_s].to_sym if @args.key?(key.to_s) } cmd = Cmds.new(template, **opts) if @args['log'] info binding.erb <<-END STREAMING ======================================================================== Template: <%= template %> Options: <%= opts.pretty_inspect %> Prepared command: <%= cmd.prepare %> END end # HACK Swap any ENV vars we replaced at the top back in $replaced_env_vars.each do |key, (original, replacement)| ENV[key] = original end cmd.stream! changed! end end Stream.new.run
Version data entries
11 entries across 11 versions & 1 rubygems