Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Bin Files #494

Open
justin808 opened this issue Jun 10, 2024 · 2 comments
Open

Simplify Bin Files #494

justin808 opened this issue Jun 10, 2024 · 2 comments

Comments

@justin808
Copy link
Member

justin808 commented Jun 10, 2024

If we use the binstubs for a pre-compilation task, like always generating some files, then let's simplify and document the bin files.

The point is to make the binstub as compact as possible so that any customizations can be identified more easily.

Current bin file https://github.com/shakacode/shakapacker/blob/main/lib/install/bin/shakapacker has:

#!/usr/bin/env ruby

ENV["RAILS_ENV"] ||= "development"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)

require "bundler/setup"
require "shakapacker"
require "shakapacker/webpack_runner"

APP_ROOT = File.expand_path("..", __dir__)
Dir.chdir(APP_ROOT) do
  Shakapacker::WebpackRunner.run(ARGV)
end

How about something like that is easier to read and modify?

#!/usr/bin/env ruby
require "shakapacker/binstub"

# Insert code here to always run before compilation

Shakapacker::Binstub.compile(ARGV)

And the same for the https://github.com/shakacode/shakapacker/blob/main/lib/install/bin/shakapacker-dev-server

@tomdracz
Copy link
Collaborator

Sorry, I don't quite follow the part here

If we'll use the binstubs for a pre-compilation task, like always generating some files, then let's simplify and document the bin files.

What do you mean around using binstubs for pre-compilation task?

Would proposed approach literally move the code in binstub to some shakapacker/binstub file? What's the use case and benefit of adding extra code there rather than to the current generated binstub?

@justin808
Copy link
Member Author

The point is to make the binstub as compact as possible so that any customizations can be identified more easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants