Skip to content

Commit

Permalink
[#27] chore: upgrade libraries to the latest versions (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelmmiguel authored Feb 13, 2022
1 parent a713006 commit 88e0de2
Show file tree
Hide file tree
Showing 3 changed files with 2,549 additions and 2,300 deletions.
33 changes: 16 additions & 17 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Requires (Native)
const fs = require('fs');
// External
const commander = require('commander');
const { program, Option } = require('commander');
const colors = require('colors/safe');
// Project
const humanFormatter = require('../lib/formatters/human');
Expand Down Expand Up @@ -49,15 +49,15 @@ const parseFile = (filePath) => {
};

// Declare the app
const app = (filePath) => {
const app = (filePath, opts) => {
let dataPromise;

if (!process.stdin.isTTY) {
dataPromise = parseStdin()
} else if (filePath) {
dataPromise = parseFile(filePath)
} else {
commander.help();
program.help();
}

dataPromise
Expand All @@ -69,15 +69,15 @@ const app = (filePath) => {
commander.dualInputs = true;
};

switch (commander.output) {
switch (opts.output) {
case 'json':
output = jsonFormatter(svg, commander);
output = jsonFormatter(svg, opts);
break;
case 'yaml':
output = yamlFormatter(svg, commander);
output = yamlFormatter(svg, opts);
break;
default:
output = humanFormatter(svg, commander);
output = humanFormatter(svg, opts);
}

// Display the output
Expand All @@ -87,10 +87,15 @@ const app = (filePath) => {
};

// Parse options and run the CLI
commander
.option('-o, --output <formatter>',
'Select the format of the output: json, yaml, or human (default)',
/^(json|yaml|human)$/i, 'human')
program
.addOption(
new Option(
"-o, --output <formatter>",
"Select the format of the output"
)
.choices(["json", "yaml", "human"])
.default("human")
)
.option('-t, --tree', 'Display only the node tree')
.option('-b, --basic', 'Display only the basic information')
.option('-s, --stats', 'Display only the node statistics')
Expand All @@ -105,9 +110,3 @@ commander
.arguments('[file|stdin]')
.action(app)
.parse(process.argv);

// If the argument is not passed, commander does not call app,
// so it must be called manually here
if (commander.args.length === 0) {
app();
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
"homepage": "https://github.com/Angelmmiguel/svgi#readme",
"dependencies": {
"ascii-tree": "^0.3.0",
"cli-table": "^0.3.1",
"colors": "^1.1.2",
"commander": "^2.9.0",
"filesize": "^3.5.10",
"js-yaml": "^3.8.4",
"xml2js": "^0.4.17"
"cli-table": "^0.3.11",
"colors": "^1.4.0",
"commander": "8.3.0",
"filesize": "^8.0.7",
"js-yaml": "^4.1.0",
"xml2js": "^0.4.23"
},
"devDependencies": {
"all-contributors-cli": "4.5.1",
"eslint": "^3.19.0",
"eslint-config-google": "^0.8.0",
"jest": "^20.0.4"
"all-contributors-cli": "6.20.0",
"eslint": "^8.8.0",
"eslint-config-google": "^0.14.0",
"jest": "^27.5.1"
}
}
Loading

0 comments on commit 88e0de2

Please sign in to comment.