Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Allow user to print at console and file in the same time (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
martincik committed Mar 8, 2022
1 parent 86c36df commit 53d9c8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ In order to retrieve the gas price of a particular blockchain, you can configure
| token | _String_ | 'ETH' | The reference token for gas price |
| gasPriceApi | _String_ | [Etherscan](https://api.etherscan.io/api?module=proxy&action=eth_gasPrice) | The API endpoint to retrieve the gas price. Find below other networks. |
| outputFile | _String_ | stdout | File path to write report output to |
| forceConsoleOutput| _Boolean_ | false | Print report output on console |
| noColors | _Boolean_ | false | Suppress report color. Useful if you are printing to file b/c terminal colorization corrupts the text. |
| onlyCalledMethods | _Boolean_ | true | Omit methods that are never called from report. |
| rst | _Boolean_ | false | Output with a reStructured text code-block directive. Useful if you want to include report in RTD |
Expand Down
1 change: 1 addition & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Config {
this.ethPrice = options.ethPrice || null;
this.gasPrice = options.gasPrice || null;
this.outputFile = options.outputFile || null;
this.forceConsoleOutput = options.forceConsoleOutput || false;
this.rst = options.rst || false;
this.rstTitle = options.rstTitle || "";
this.showTimeSpent = options.showTimeSpent || false;
Expand Down
10 changes: 7 additions & 3 deletions lib/gasTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,13 @@ class GasTable {
// ---------------------------------------------------------------------------------------------
// Print
// ---------------------------------------------------------------------------------------------
this.config.outputFile
? fs.writeFileSync(this.config.outputFile, tableOutput)
: console.log(tableOutput);
if (this.config.outputFile) {
fs.writeFileSync(this.config.outputFile, tableOutput);
if (this.config.forceConsoleOutput)
console.log(tableOutput);
} else {
console.log(tableOutput);
}

this.saveCodeChecksData(info);

Expand Down

0 comments on commit 53d9c8e

Please sign in to comment.