Sha256: 3ea8c2d7ec1d1ab1dbe36c6982b7e65afdb4dab6dbc29229605e23b8060c3bfb
Contents?: true
Size: 1.47 KB
Versions: 6
Compression:
Stored size: 1.47 KB
Contents
# frozen_string_literal: true require "English" require "rake/file_utils" module Shakapacker module Utils class Misc extend FileUtils def self.use_package_json_gem ENV.fetch("SHAKAPACKER_USE_PACKAGE_JSON_GEM", "false").casecmp("true").zero? end def self.require_package_json_gem unless use_package_json_gem raise "PackageJson should not be used unless SHAKAPACKER_USE_PACKAGE_JSON_GEM is true" end require "package_json" end def self.uncommitted_changes?(message_handler) return false if ENV["COVERAGE"] == "true" status = `git status --porcelain` return false if $CHILD_STATUS.success? && status.empty? error = if $CHILD_STATUS.success? "You have uncommitted code. Please commit or stash your changes before continuing" else "You do not have Git installed. Please install Git, and commit your changes before continuing" end message_handler.add_error(error) true end def self.object_to_boolean(value) [true, "true", "yes", 1, "1", "t"].include?(value.instance_of?(String) ? value.downcase : value) end # Executes a string or an array of strings in a shell in the given directory in an unbundled environment def self.sh_in_dir(dir, *shell_commands) shell_commands.flatten.each { |shell_command| sh %(cd '#{dir}' && #{shell_command.strip}) } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems