doyensec / electronegativity

Electronegativity is a tool to identify misconfigurations and security anti-patterns in Electron applications.
Apache License 2.0
972 stars 66 forks source link

Fixes #59: Allow running electronegativity programmatically #64

Closed baltpeter closed 4 years ago

baltpeter commented 4 years ago

As requested in #59, this PR adds the ability to run electronegativity programmatically.

This is mainly achieved by replacing the main field in the package.json with dist/runner.js. Running the CLI still works as the bin field still references dist/index.js.

I think users of the programmatic interface will also appreciate not having the implement the preparation done in runner.js themselves, so I have opted to refactor the run() function to make it usable both as a CLI and programmatically by introducing an optional isCli parameter. This unfortunately requires quite a few new conditionals in that function, so let me know if you prefer a different implementation.

I have also included the add-module-exports Babel plugin, so users don't have to explicitly specify the default export (require('@doyensec/electronegativity').default). If you would prefer not to use this plugin, let me know.

phosphore commented 4 years ago

Hey @baltpeter! Thank you for this awesome contribution :clap: With this change even more developers will be able to easily integrate Electronegativity in their CI/CAS pipeline!