Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP feat: add command line utility #120

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
lib/compiled-config.js
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
dist
57 changes: 57 additions & 0 deletions bin/linting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env node

/* eslint-env node */

const fs = require('fs');

const {
green,
red
} = require('ansi-colors');

const { Linter } = require('../dist/Linter.js');

const linter = new Linter();

const files = process.argv.filter(arg => arg.endsWith('.bpmn'));

if (files.length === 0) {
console.error('No files found');

process.exit(1);
}

console.log(`Linting ${files.length} file(s)`);

let errors = 0;

files.forEach((file) => {
try {
const content = fs.readFileSync(file, 'utf8');

linter.lint(content).then((results) => {
if (!results.length) {
console.log(green(file));

return;
}

errors += results.length;

console.log(red(file));

results.forEach((result) => {
console.log(red(`\t[${result.id}] ${result.message}`));
});
});

} catch (err) {
console.error(`Error reading ${file}:`, err);
}
});

process.on('exit', () => {
if (errors) {
process.exit(1);
}
});
Loading
Loading