Skip to content

Commit

Permalink
fix: incorrect util function
Browse files Browse the repository at this point in the history
  • Loading branch information
Newton Koumantzelis committed Mar 25, 2020
1 parent e563c9a commit bcb155e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env node

const pkg = require('../package.json');
const cli = require('../src/cli');
const { aliases, copyright, usage } = require('../src/options');
/* eslint-disable import/order */
const updateNotifier = require('update-notifier');
const { aliases, copyright, usage } = require('../src/options');
const options = require('yargs')
.usage(usage)
.commandDir('../src/cmds')
Expand All @@ -14,6 +13,8 @@ const options = require('yargs')
.version()
.epilogue(copyright)
.argv;
const pkg = require('../package.json');
const cli = require('../src/cli');

updateNotifier({ pkg }).notify();

Expand Down
6 changes: 3 additions & 3 deletions src/cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { file, log, str } = require('@theholocron/chopper');
const ora = require('ora');
const api = require('./');
const { isExtends } = require('./utils');
const api = require('./');

async function cli (options) {
const browserstats = `browserslist-stats.json`;
Expand All @@ -28,7 +28,7 @@ async function cli (options) {
// file to use locally
// @TODO: needs to read current file to amend using readline
const rcfile = './.browserslistrc';
log.error('Feature not ready');
log.error(`${rcfile} support is not ready`);
break;
}

Expand Down Expand Up @@ -65,7 +65,7 @@ async function cli (options) {

if (!str.toFileSync(data, pkgfile)) {
options.spinner.stop();
log.error(`There was an error writing ${path} to the file system!`);
log.error(`There was an error writing ${pkgfile} to the file system!`);
process.exit(1);
}
str.toJSONFile(data, pkgfile);
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/write.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
exports.aliases = [ 'write-file' ];
exports.command = 'write [source]';
exports.builder = yargs => yargs.positional('source', {
choices: ['config', 'file', 'package'],
choices: [ 'config', 'file', 'package' ],
default: 'config',
describe: 'Where to write the usage stats, either a config file or within the package',
});
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const api = {
const middleIndex = Math.floor(usageStatsAboveZero.length / 2);

if (usageStatsAboveZero.length % 2) {
return values[middleIndex][1];
return data[middleIndex][1];
}

return (usageStatsAboveZero[middleIndex - 1][1] + usageStatsAboveZero[middleIndex + 1][1]) / 2;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ const combineVendorWithVersion = ([ vendor, versions ]) => Object
.keys(versions)
.reduce((acc, version) => ({
...acc,
[`${vendor}${version}`]: versions[version]
[`${vendor}${version}`]: versions[version],
}), {});

// a reducer to flatten out the vendros with version
const flattenVendorVersions = (acc, vendorVersion) => [
...acc,
...Object.entries(vendorVersion)
...Object.entries(vendorVersion),
];

// filter for removing all browsers/versions with zero for a value
Expand Down

0 comments on commit bcb155e

Please sign in to comment.