Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions sdflint/sdflint.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ if (require.main === module) { /* run as stand-alone? */
let schemaFile;

process.argv.slice(3).forEach((option) => {
let name = option.substring(0, option.indexOf("="));
let value = option.substring(option.indexOf("=") + 1);
let eqIndex = option.indexOf("=");
if (eqIndex === -1) {
console.error("Invalid option (missing '='): " + option);
process.exitCode = 1;
return;
}
let name = option.substring(0, eqIndex);
let value = option.substring(eqIndex + 1);
options[name] = value;
});

Expand All @@ -63,7 +69,7 @@ if (require.main === module) { /* run as stand-alone? */
sdfLint(sdfFile, schema, res, options);
console.dir(res, { depth: null });

process.exit(res.errorCount);
process.exitCode = res.errorCount;
}
else {
console.log(`
Expand All @@ -90,8 +96,7 @@ function fileNameCheck(fileName, res) {
}


function validCharsCheck(sdfFile, res) {
let sdfStr = JSON.stringify(sdfFile);
function validCharsCheck(sdfStr, res) {
if (!sdfStr) {
res.errorCount++;
res.errors.file = "Invalid SDF file";
Expand Down Expand Up @@ -140,6 +145,7 @@ function sdfLint(sdfFile, schema, res, options) {
} catch (err) {
res.errorCount++;
res.errors.parse = err.message;
return res;
}
validCharsCheck(sdfFile, res);
}
Expand Down