diff --git a/bin/ConvertBTC.js b/bin/ConvertBTC.js index 0805fcd..9ba8428 100644 --- a/bin/ConvertBTC.js +++ b/bin/ConvertBTC.js @@ -2,6 +2,12 @@ var request = require('request'); var chalk = require('chalk'); +var ora = require('ora'); + +var spinner = ora({ + text: 'Retrieving Bitcoin data...', + color: 'yellow' +}); /* eslint consistent-return: 0 */ function convertBTC() { @@ -9,8 +15,10 @@ function convertBTC() { var amount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1; var url = 'https://apiv2.bitcoinaverage.com/convert/global?from=BTC&to=' + currency + '&amount=' + amount; + spinner.start(); request(url, function (error, response, body) { var apiResponse = void 0; + spinner.stop(); try { apiResponse = JSON.parse(body); } catch (parseError) { diff --git a/src/ConvertBTC.js b/src/ConvertBTC.js index 6501334..bf60d0d 100644 --- a/src/ConvertBTC.js +++ b/src/ConvertBTC.js @@ -1,11 +1,19 @@ const request = require('request'); const chalk = require('chalk'); +const ora = require('ora'); + +const spinner = ora({ + text: 'Retrieving Bitcoin data...', + color: 'yellow', +}); /* eslint consistent-return: 0 */ function convertBTC(currency = 'USD', amount = 1) { const url = `https://apiv2.bitcoinaverage.com/convert/global?from=BTC&to=${currency}&amount=${amount}`; + spinner.start(); request(url, (error, response, body) => { let apiResponse; + spinner.stop(); try { apiResponse = JSON.parse(body); } catch (parseError) { diff --git a/tests/ConvertBTC.spec.js b/tests/ConvertBTC.spec.js index 4db74c3..55ef44e 100644 --- a/tests/ConvertBTC.spec.js +++ b/tests/ConvertBTC.spec.js @@ -3,6 +3,7 @@ const chai = require('chai'); const sinon = require('sinon'); const sinonChai = require('sinon-chai'); const chalk = require('chalk'); +const ora = require('ora'); const expect = chai.expect;