@rmlio/yarrrml-parser
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
const program = require('commander'); | ||
const { program } = require('commander'); | ||
const path = require('path'); | ||
@@ -27,17 +27,19 @@ const fs = require('fs'); | ||
if (!program.input) { | ||
const options = program.opts(); | ||
if (!options.input) { | ||
Logger.error('Please provide an input file.'); | ||
} else { | ||
if (!path.isAbsolute(program.input)) { | ||
program.input = path.join(process.cwd(), program.input); | ||
if (!path.isAbsolute(options.input)) { | ||
options.input = path.join(process.cwd(), options.input); | ||
} | ||
try { | ||
const inputData = fs.readFileSync(program.input, 'utf8'); | ||
const inputData = fs.readFileSync(options.input, 'utf8'); | ||
if (program.format) { | ||
program.format = program.format.toUpperCase(); | ||
if (options.format) { | ||
options.format = options.format.toUpperCase(); | ||
} | ||
const parser = N3.Parser(); | ||
const parser = new N3.Parser(); | ||
const quads = []; | ||
@@ -53,11 +55,11 @@ | ||
toYARRRML(quads, prefixes).then(str => { | ||
if (program.output) { | ||
if (!path.isAbsolute(program.output)) { | ||
program.output = path.join(process.cwd(), program.output); | ||
if (options.output) { | ||
if (!path.isAbsolute(options.output)) { | ||
options.output = path.join(process.cwd(), options.output); | ||
} | ||
try { | ||
fs.writeFileSync(program.output, str); | ||
fs.writeFileSync(options.output, str); | ||
} catch (e) { | ||
Logger.error(`The RML could not be written to the output file ${program.output}`); | ||
Logger.error(`The RML could not be written to the output file ${options.output}`); | ||
} | ||
@@ -73,3 +75,3 @@ } else { | ||
if (e.code === 'ENOENT') { | ||
Logger.error(`The input file ${program.input} is not found.`); | ||
Logger.error(`The input file ${options.input} is not found.`); | ||
} else if (e.code === 'INVALID_YAML') { | ||
@@ -76,0 +78,0 @@ Logger.error(`The input file contains invalid YAML.`); |
@@ -8,3 +8,3 @@ #!/usr/bin/env node | ||
const program = require('commander'); | ||
const { program } = require('commander'); | ||
const path = require('path'); | ||
@@ -46,3 +46,5 @@ const fs = require('fs'); | ||
if (!program.input) { | ||
const options = program.opts(); | ||
if (!options.input) { | ||
Logger.error('Please provide an input file using -i| --input.'); | ||
@@ -52,3 +54,3 @@ } else { | ||
for (let input of program.input) { | ||
for (let input of options.input) { | ||
// Check if the input is a regex, e.g., *.yarrrml | ||
@@ -67,3 +69,3 @@ if (glob.hasMagic(input)) { | ||
if (!program.watch) { | ||
if (!options.watch) { | ||
try { | ||
@@ -77,4 +79,4 @@ const inputData = []; | ||
if (program.format) { | ||
program.format = program.format.toUpperCase(); | ||
if (options.format) { | ||
options.format = options.format.toUpperCase(); | ||
} | ||
@@ -98,3 +100,3 @@ | ||
for (const e of program.external) { | ||
for (const e of options.external) { | ||
const keyValue = e.split('='); | ||
@@ -104,6 +106,6 @@ externalReferences[keyValue[0]] = keyValue[1]; | ||
const includeMetadata =!(!!program.skipMetadata); | ||
const includeMetadata =!(!!options.skipMetadata); | ||
if (!program.format || program.format === 'RML') { | ||
const y2r = new Y2R({class: !!program.class, externalReferences, includeMetadata}); | ||
if (!options.format || options.format === 'RML') { | ||
const y2r = new Y2R({class: !!options.class, externalReferences, includeMetadata}); | ||
triples = y2r.convert(inputData); | ||
@@ -116,3 +118,3 @@ | ||
} else { | ||
const y2r = new Y2R2({class: !!program.class, externalReferences, includeMetadata}); | ||
const y2r = new Y2R2({class: !!options.class, externalReferences, includeMetadata}); | ||
triples = y2r.convert(inputData); | ||
@@ -127,11 +129,11 @@ prefixes[''] = y2r.getBaseIRI(); | ||
writer.end((error, result) => { | ||
if (program.output) { | ||
if (!path.isAbsolute(program.output)) { | ||
program.output = path.join(process.cwd(), program.output); | ||
if (options.output) { | ||
if (!path.isAbsolute(options.output)) { | ||
options.output = path.join(process.cwd(), options.output); | ||
} | ||
try { | ||
fs.writeFileSync(program.output, result); | ||
fs.writeFileSync(options.output, result); | ||
} catch (e) { | ||
Logger.error(`The RML could not be written to the output file ${program.output}`); | ||
Logger.error(`The RML could not be written to the output file ${options.output}`); | ||
} | ||
@@ -145,3 +147,3 @@ } else { | ||
if (e.code === 'ENOENT') { | ||
Logger.error(`The input file ${program.input} is not found.`); | ||
Logger.error(`The input file ${options.input} is not found.`); | ||
} else if (e.code === 'INVALID_YAML') { | ||
@@ -155,4 +157,4 @@ Logger.error(`The input file contains invalid YAML.`); | ||
} else { | ||
watch(program.input, program.output, program.format); | ||
watch(options.input, options.output, options.format); | ||
} | ||
} |
@@ -10,2 +10,9 @@ # Changelog | ||
## [1.2.3] - 2021-05-28 | ||
### Fixed | ||
- Fix N3 outdated constructor (see [issue 115](https://github.com/RMLio/yarrrml-parser/issues/115)) | ||
- updated commander | ||
## [1.2.2] - 2021-02-23 | ||
@@ -207,2 +214,3 @@ | ||
[1.2.3]: https://github.com/RMLio/yarrrml-parser/compare/v1.2.2...v1.2.3 | ||
[1.2.2]: https://github.com/RMLio/yarrrml-parser/compare/v1.2.1...v1.2.2 | ||
@@ -209,0 +217,0 @@ [1.2.1]: https://github.com/RMLio/yarrrml-parser/compare/v1.2.0...v1.2.1 |
{ | ||
"name": "@rmlio/yarrrml-parser", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Parse YARRRML descriptions into RML RDF statements", | ||
@@ -21,3 +21,3 @@ "main": "lib/yarrrml2rml.js", | ||
"dependencies": { | ||
"commander": "^2.20.3", | ||
"commander": "^7.2.0", | ||
"extend": "^3.0.2", | ||
@@ -24,0 +24,0 @@ "glob": "^7.1.6", |
458608
231
4623
+ Addedcommander@7.2.0(transitive)
- Removedcommander@2.20.3(transitive)
Updatedcommander@^7.2.0