New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cbr-rates-cli

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cbr-rates-cli - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

index.es5.js

46

cli.js
#!/usr/bin/env node
import chalk from 'chalk';
import cbrRates from 'cbr-rates';
import each from 'ea';
import indentString from 'indent-string';
import meow from 'meow';
const cli = meow(`
Usage
cbr-rates [date]
Examples
cbr-rates
cbr-rates 2014.5.12
`);
const dateString = cli.input[0];
let date;
if (dateString) {
const [year, month, day] = dateString.split('.');
date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day));
}
cbrRates(date, (err, rates) => {
if (err) return;
const values = [];
each(rates, ({value}) => {
values.push(value);
});
const length = integerLength(Math.max(...values));
each(rates, ({par, value}, id) => {
const indent = length - integerLength(value);
id = id.toUpperCase();
value = indentString(value.toFixed(2), ' ', indent);
console.log(`${id} ${chalk.bold(value)} ${chalk.grey(par)}`);
});
});
function integerLength(num) {
return Math.floor(num).toFixed().toString().length;
}
'use strict';
require('./index.es5');
{
"name": "cbr-rates-cli",
"description": "Get currency rates from Central Bank of Russia",
"version": "0.2.5",
"version": "0.2.6",
"keywords": [

@@ -15,3 +15,3 @@ "cbr",

"dependencies": {
"cbr-rates": "^0.2.0",
"cbr-rates": "^0.3.2",
"chalk": "^1.1.0",

@@ -23,13 +23,15 @@ "ea": "^0.5.0",

"devDependencies": {
"ava": "^0.2.0",
"babel": "^5.5.6"
"ava": "^0.7.0",
"babel-cli": "^6.3.15",
"babel-preset-es2015": "^6.3.13",
"execa": "^0.1.1"
},
"bin": {
"cbr-rates": "cli.es5.js"
"cbr-rates": "cli.js"
},
"scripts": {
"test": "babel-node test.js",
"transpile": "babel --stage 0 cli.js > cli.es5.js",
"prepublish": "npm run transpile",
"postpublish": "rm -rf *.es5.js"
"pretest": "npm run prepublish",
"test": "ava",
"prepublish": "babel --presets es2015 index.js --out-file index.es5.js",
"postpublish": "rm -rf index.es5.js && git push --follow-tags"
},

@@ -36,0 +38,0 @@ "author": "Andrey Polischuk <andre.polischuk@gmail.com>",

import test from 'ava';
import {exec} from 'child_process';
const babel = __dirname + '/node_modules/.bin/babel-node';
import execa from 'execa';
test('should return last rates', t => {
t.plan(2);
exec(`${babel} cli.js`, {cwd: __dirname}, (err, stdout) => {
t.ifError(err);
t.true(stdout.trim().indexOf('USD') > 0);
});
test('should return last rates', async t => {
const {stdout} = await execa('./cli.js');
t.true(stdout.trim().indexOf('USD') > 0);
});
test('should return rates for specified date', t => {
t.plan(2);
exec(`${babel} cli.js 2015.5.15`, {cwd: __dirname}, (err, stdout) => {
t.ifError(err);
t.true(stdout.trim().indexOf('USD') > 0);
});
test('should return rates for specified date', async t => {
const {stdout} = await execa('./cli.js', ['2015.5.15']);
t.true(stdout.trim().indexOf('USD') > 0);
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc