rubysec / bundler-audit

Patch-level verification for Bundler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can no longer be called programatically

nello opened this issue · comments

Attempting to use as per this (2015) documentation: http://caseywest.com/run-bundle-audit-from-rake/

Now calling Bundler::Audit::CLI.new.check fails to report anything, but just says "Unknown format:".

It looks like somewhere along the line, default formatting has stopped working. Is there any way to do this now?

That error is likely due to how Thor (which Bundler::Audit::CLI uses) doesn't initialize default values for options when you directly initialize the Thor sub-class object.

There is now a rake task you can use directly in the Rakefile.

require 'bundler/audit/task'
Bundler::Audit::Task.new

The rake task just calls system('...'). Are you saying there is now no way to invoke the application programatically directly?

I did not say that. If you want to invoke bundle-audit programmatically (which is not recommended, because it is a CLI util, not a library), then see the API documentation. It is not recommended to directly invoke Bundler::Audit::CLI as it is a Thor app, and cannot simply be initialized with .new. If you need to automate bundler-audit then simply use the rake tasks provided by bundler/audit/task or write your own rake tasks which invoke system('bundle-audit', ...) with specific arguments.

btw the way you are supposed to invoke Thor apps directly is via the .start(["arg1", ...]) method, if that helps. The .start method does additional initialization beyond what .new does.

Thanks