Skip to content

Commit

Permalink
Merge branch 'main' of github.com:kevincolyer/poloniexreportjs into main
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincolyer committed Sep 5, 2022
2 parents ec7293d + 2f3873a commit 09dea77
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions node-polo.demo.js
@@ -1,8 +1,5 @@
'use strict'

const SAVEDATA = true;
const LOADDATA = false;

// Bring in the ability to create the 'require' method
import {
createRequire
Expand Down Expand Up @@ -30,6 +27,23 @@ const {
secure,
} = require('./auth.json'); // use the require method

// Program options
const OPTIONS = {
'SAVEDATA': false,
'LOADDATA': false,
'SENDEMAIL': true
};

// Process CLI
const myArgs = process.argv.slice(2);
if (myArgs.includes('--no-email')) {
OPTIONS['SENDEMAIL'] = false
};

// Set programe option flags
const LOADDATA = OPTIONS['LOADDATA'];
const SAVEDATA = OPTIONS['SAVEDATA'];

// nasty global variable
let timestamp = new Date().getTime()

Expand Down Expand Up @@ -544,7 +558,8 @@ for (let coin of myBalances) {
}
}

tableOfCoins.sort((a, b) => b[4] - a[4]);
// sort by column 4 but strip out commas first!
tableOfCoins.sort((a, b) => +b[4].replaceAll(',', '') - +a[4].replaceAll(',', ''));

tableOfCoins.push(['', '', '', 'TOTALS', moneydollar(tot_usd), moneybitcoin(tot_btc)]);

Expand All @@ -564,6 +579,10 @@ report += "\n";
console.log(report)
console.log("Load data=", LOADDATA);

// regexp to strip console colours
var textReport = report.replace(
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g, '');
sendEmailReport(textReport);

if (OPTIONS['SENDEMAIL']) {
sendEmailReport(textReport)
};

0 comments on commit 09dea77

Please sign in to comment.