bpmn-io / bpmnlint

Validate BPMN diagrams based on configurable lint rules.
MIT License
121 stars 36 forks source link

Support glob/pattern lint (e.g. bpmnlint **/*.bpmn) #46

Closed clementdessoude closed 3 years ago

clementdessoude commented 3 years ago

Is your feature request related to a problem? Please describe

Hi !

First, thank you for this great tool !

We were trying to integrate it on our project, but we had some difficulties to make it work in a npm script, because it doesn't seems to support glob/pattern search.

For instance, when creating a script npm run check-bpmn, I got this kind of error:

bpmnlint src/**/*.bpmn

Error: Failed to read src/**/*.bpmn

Describe the solution you'd like

I would like to propose supporting glob search.

Describe alternatives you've considered

I think that otherwise, we'll try to implement a wrapper that will give us the same functionnality

nikku commented 3 years ago

I imagine you're on Windows? On Unix globbing should work out of the box, right?

clementdessoude commented 3 years ago

No, I'm on MacOs. But it seems that glob star are not by default supported:

OS X ships with bash-3.2 but globstar (** → globstar matches zero or more directories and subdirectories) is supported starting from Bash version 4.0. Windows command shell also doesn’t support wildcard expansion.

https://medium.com/@jakubsynowiec/you-should-always-quote-your-globs-in-npm-scripts-621887a2a784

MaxTru commented 3 years ago

I am on Linux and wasn't sure about this. But IMO this does not work out of the box with Linux (I also tested it locally on Arch Linux, Bash 5.0.x).

Without this PR

$ node bpmnlint.js "../test/**/valid-spl*.bpmn"

Error: Failed to read ../test/**/valid-spl*.bpmn

With this PR

node bpmnlint.js ../test/**/valid-spl*.bpmn 

/home/maxtru/Dokumente/10_modules/commPullRequests/bpmnlint/test/rules/conditional-flows/valid-split-after-task.bpmn
  Process   error  Process is missing end event    end-event-required  
  Target_1  error  Element is missing label/name   label-required      
  Target_2  error  Element is missing label/name   label-required      
[...]
nikku commented 3 years ago

@MaxTru You'd need to remove the "ticks" for expansion to work.

> npx bpmnlint ~/Downloads/**/*.bpmn
...
...
✖ 662 problems (591 errors, 71 warnings)

Obviously you'd need a shell that supports ** expansion (on bash, this may need to be explicitly enabled).