Sha256: 00fa1b2277d7908c06ddb1a23f5ba002f561818359cb5413d2bf35e73064773f

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'lerna/runner'
require 'lerna/strategy'

LOGGER = lambda { |str|
  time = Time.now.utc
  timestamp = time.strftime('%Y-%m-%dT%H:%M:%S.') << '%06dZ' % time.usec
  puts '[%s #%d] %s' % [timestamp, Process.pid, str]
}

options = {
  strategies: %w[ dual-external external-digital-only internal-only ],
  system: method(:system)
}

executable = File.basename(__FILE__)

parser = OptionParser.new { |opts|
  opts.banner = "Usage: #{executable} [options]"
  opts.on(
    '-s', '--strategies', String,
    'Strategies in order of precedence, separated by commas',
    "Default is #{options[:strategies].join(',')}",
    "Available: #{Lerna::Strategy.registry.keys.join(' ')}"
  ) do |str|
    options[:strategies] = str.split(/,/)
  end
  opts.on(
    '-d', '--dry-run',
    'Just log the actions that would be taken'
  ) do
    options[:system] = ->(*args) { LOGGER.call(args.join(' ')) }
  end
  opts.on(
    "-h", "--help",
    "Display this help message and exit"
  ) do
    puts opts
    exit
  end
}
parser.parse!

runner = Lerna::Runner.new(
  logger: LOGGER,
  strategies: options[:strategies],
  system: options[:system]
)

trap('TERM') {
  LOGGER.call('Exiting')
  exit
}

loop do
  runner.run
  sleep 2
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lerna-0.1.0 bin/lerna