Skip to content

Commit

Permalink
Refactor cmd.command checks into _jsonLdOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
BigBlueHat committed Mar 27, 2024
1 parent f2ef260 commit 5b2e13c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions bin/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ function _jsonLdOptions(command, input) {
options.safe = true;
}

if(command.context) {
options.expandContext = command.context;
}

options.base = _getBase(command, input);

// setup documentLoader
Expand Down Expand Up @@ -267,9 +271,6 @@ _jsonLdCommand(program.command('format [filename|URL|-]'))
if(cmd.json) {
options.format = 'application/json';
}
if(cmd.context) {
options.expandContext = cmd.context;
}

let result;
switch(options.format.toLowerCase()) {
Expand Down Expand Up @@ -305,9 +306,6 @@ _jsonLdCommand(program.command('lint [filename|URL|-]'))
.action(async function lint(input, cmd) {
input = input || '-';
const options = _jsonLdOptions(cmd, input);
if(cmd.context) {
options.expandContext = cmd.context;
}

await jsonld.expand(input, {
...options,
Expand Down Expand Up @@ -342,9 +340,6 @@ _jsonLdCommand(program.command('expand [filename|URL|-]'))
.action(async function expand(input, cmd) {
input = input || '-';
const options = _jsonLdOptions(cmd, input);
if(cmd.context) {
options.expandContext = cmd.context;
}
options.keepFreeFloatingNodes = cmd.keepFreeFloatingNodes;

const result = await jsonld.expand(input, options);
Expand Down

0 comments on commit 5b2e13c

Please sign in to comment.