lib/vite_ruby/commands.rb in vite_ruby-1.0.5 vs lib/vite_ruby/commands.rb in vite_ruby-1.1.0
- old
+ new
@@ -6,21 +6,21 @@
def initialize(vite_ruby)
@vite_ruby = vite_ruby
end
# Public: Defaults to production, and exits if the build fails.
- def build_from_task
+ def build_from_task(*args)
with_node_env(ENV.fetch('NODE_ENV', 'production')) {
ensure_log_goes_to_stdout {
- build || exit!
+ build(*args) || exit!
}
}
end
# Public: Builds all assets that are managed by Vite, from the entrypoints.
- def build
- builder.build.tap { manifest.refresh }
+ def build(*args)
+ builder.build(*args).tap { manifest.refresh }
end
# Public: Removes all build cache and previously compiled assets.
def clobber
config.build_output_dir.rmtree if config.build_output_dir.exist?
@@ -147,12 +147,14 @@
ensure
ENV['NODE_ENV'] = original
end
def ensure_log_goes_to_stdout
- old_logger = logger
- self.logger = Logger.new($stdout)
+ old_logger, original_sync = logger, $stdout.sync
+
+ $stdout.sync = true
+ self.logger = Logger.new($stdout, formatter: proc { |_, _, progname, msg| progname == 'vite' ? msg : "#{ msg }\n" })
yield
ensure
- self.logger = old_logger
+ self.logger, $stdout.sync = old_logger, original_sync
end
end