From 266cf677918657f87bdb4221504f905554224a81 Mon Sep 17 00:00:00 2001 From: Fabian Steeg Date: Wed, 10 Oct 2018 14:15:18 +0200 Subject: [PATCH] Use jsonld_request to embed local context during compaction For usage like `jsonld compact -c context.json doc.json` See https://github.com/digitalbazaar/jsonld-cli/issues/8 --- bin/jsonld | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/jsonld b/bin/jsonld index e678599..a9a27bd 100755 --- a/bin/jsonld +++ b/bin/jsonld @@ -232,7 +232,14 @@ _jsonLdCommand(program.command('compact [filename|URL]')) options.compactArrays = cmd.compactArrays; options.graph = !!cmd.graph; - jsonld.compact(input, cmd.context, options, callback); + if(_isHTTP(cmd.context)) { + jsonld.compact(input, cmd.context, options, callback); + } else { + jsonld_request(cmd.context, function(err, res, context) { + if(err) { throw err; } + jsonld.compact(input, context, options, callback); + }); + } }], output: ['process', function(results, callback) { _output(results.process, cmd, callback);