Skip to content

Commit

Permalink
Fix: remove dependency to minimist (#236)
Browse files Browse the repository at this point in the history
* Use util.parseArgs instead of minimist

* Update package-lock.json

* 0.5.2

* Remove minimist
  • Loading branch information
ralfhandl authored Feb 13, 2024
1 parent 9c9a095 commit d278339
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 78 deletions.
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,14 @@
},
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"cSpell.words": ["CSDL", "OData", "depr", "emph", "qname", "rarr", "vola"]
"cSpell.words": [
"CSDL",
"depr",
"emph",
"OData",
"positionals",
"qname",
"rarr",
"vola"
]
}
40 changes: 19 additions & 21 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,26 @@

const csdl = require("odata-csdl");
const lib = require("./csdl2markdown");
const minimist = require("minimist");
const fs = require("fs");
const { parseArgs } = require("node:util");
const fs = require("node:fs");

var unknown = false;
let unknown = false;

var argv = minimist(process.argv.slice(2), {
string: ["t", "target"],
boolean: ["h", "help"],
alias: {
h: "help",
t: "target",
},
unknown: (arg) => {
if (arg.substring(0, 1) == "-") {
console.error("Unknown option: " + arg);
unknown = true;
return false;
}
},
});
let args;
try {
args = parseArgs({
options: {
help: { type: "boolean", short: "h" },
target: { type: "string", short: "t" },
},
allowPositionals: true,
});
} catch (e) {
console.error(e.message);
unknown = true;
}

if (unknown || argv._.length == 0 || argv.h) {
if (unknown || args.positionals.length !== 1 || args.values.help) {
console.log(`Usage: odata-vocab2md <options> <source file>
Options:
-h, --help show this info
Expand All @@ -36,7 +34,7 @@ Options:
// for (var i = 0; i < argv._.length; i++) {
// convert(argv._[i]);
// }
convert(argv._[0]);
convert(args.positionals[0]);
}

function convert(source) {
Expand All @@ -56,7 +54,7 @@ function convert(source) {
}

const target =
argv.target ||
args.values.target ||
(source.lastIndexOf(".") <= 0
? source
: source.substring(0, source.lastIndexOf("."))) + ".md";
Expand Down
139 changes: 86 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "odata-vocabularies",
"version": "0.5.1",
"version": "0.5.2",
"description": "Convert OData vocabularies in CSDL XML or CSDL JSON to GitHub Flavored Markdown",
"homepage": "https://github.com/oasis-tcs/odata-vocabularies/blob/main/lib/README.md",
"bugs": "https://github.com/oasis-tcs/odata-vocabularies/issues",
Expand All @@ -17,8 +17,7 @@
"main": "lib/csdl2markdown.js",
"dependencies": {
"colors": "^1.4.0",
"minimist": "^1.2.6",
"odata-csdl": "^0.9.4"
"odata-csdl": "^0.9.5"
},
"devDependencies": {
"c8": "^9.1.0",
Expand Down

0 comments on commit d278339

Please sign in to comment.