-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "replace binstub with spring command"
This reverts commit f553edc.
- Loading branch information
1 parent
52c06c9
commit 2678be4
Showing
6 changed files
with
81 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# typed: true | ||
# frozen_string_literal: true | ||
|
||
module Packwerk | ||
module Generators | ||
class Binstub | ||
class << self | ||
def generate(root: ".", out: $stdout) | ||
new(root, out: out).generate | ||
end | ||
end | ||
|
||
def initialize(root, out: $stdout) | ||
@root = root | ||
@out = out | ||
end | ||
|
||
def generate | ||
@out.puts("📦 Generating binstub...") | ||
generate_packwerk_validate_script | ||
end | ||
|
||
private | ||
|
||
def generate_packwerk_validate_script | ||
destination_file_path = File.join(@root, "bin") | ||
FileUtils.mkdir_p(destination_file_path) | ||
|
||
if File.exist?(File.join(destination_file_path, "packwerk")) | ||
@out.puts("⚠️ Packwerk binstub already exists.") | ||
return true | ||
end | ||
|
||
source_file_path = File.expand_path("templates/packwerk", __dir__) | ||
FileUtils.cp(source_file_path, destination_file_path) | ||
|
||
@out.puts("✅ Packwerk binstub generated in #{destination_file_path}") | ||
true | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# typed: false | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
module Packwerk | ||
module Generators | ||
class BinstubTest < Minitest::Test | ||
setup do | ||
@string_io = StringIO.new | ||
@temp_dir = Dir.mktmpdir | ||
FileUtils.mkdir_p(Pathname.new(@temp_dir).join("bin")) | ||
@generated_file_path = File.join(@temp_dir, "bin", "packwerk") | ||
end | ||
|
||
teardown do | ||
FileUtils.remove_entry(@temp_dir) | ||
end | ||
|
||
test ".generate creates a bin/packwerk file" do | ||
success = Packwerk::Generators::Binstub.generate(root: @temp_dir, out: @string_io) | ||
assert(File.exist?(@generated_file_path)) | ||
assert success | ||
assert_includes @string_io.string, "binstub generated" | ||
end | ||
|
||
test ".generate does not create a bin/packwerk file if bin/packwerk already exists" do | ||
File.open(File.join(@temp_dir, "bin/packwerk"), "w") do |_f| | ||
success = Packwerk::Generators::Binstub.generate(root: @temp_dir, out: @string_io) | ||
assert success | ||
assert_includes @string_io.string, "binstub already exists" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.