-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules | ||
node_modules | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs'); | ||
Check failure on line 3 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
|
||
const { | ||
green, | ||
red | ||
} = require('ansi-colors'); | ||
Check failure on line 8 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
|
||
const { Linter } = require('../dist/Linter.js'); | ||
Check failure on line 10 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
|
||
const linter = new Linter(); | ||
|
||
const files = process.argv.filter(arg => arg.endsWith('.bpmn')); | ||
Check failure on line 14 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
|
||
if (files.length === 0) { | ||
console.error('No files found matching the pattern:', pattern); | ||
Check failure on line 17 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
|
||
process.exit(1); | ||
Check failure on line 19 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
} | ||
|
||
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', () => { | ||
Check failure on line 51 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
if (errors) { | ||
process.exit(1); | ||
Check failure on line 53 in bin/linting.js GitHub Actions / Build (ubuntu-latest, 20)
|
||
} | ||
}); |