1
1
import chalk from 'chalk' ;
2
2
import type { Disk } from '../lib/disk' ;
3
3
import type { ProgramInput } from '../lib/get-input' ;
4
+ import { isValidSemverRange } from '../lib/is-semver' ;
4
5
import { setSemverRange } from '../lib/set-semver-range' ;
5
6
import { listSemverGroupMismatches } from './list-semver-group-mismatches' ;
6
7
@@ -13,25 +14,25 @@ export function lintSemverRanges(input: ProgramInput, disk: Disk): void {
13
14
* will then start from index 1.
14
15
*/
15
16
input . instances . semverGroups . reverse ( ) . forEach ( ( semverGroup , i ) => {
16
- if ( ! ( 'range' in semverGroup && semverGroup . range ) ) return ;
17
+ if ( 'range' in semverGroup && isValidSemverRange ( semverGroup . range ) ) {
18
+ const isSemverGroup = i > 0 ;
19
+ const mismatches = listSemverGroupMismatches ( semverGroup ) ;
17
20
18
- const isSemverGroup = i > 0 ;
19
- const mismatches = listSemverGroupMismatches ( semverGroup ) ;
21
+ if ( isSemverGroup && mismatches . length > 0 ) {
22
+ console . log ( chalk `{dim = Semver Group ${ i } ${ '=' . repeat ( 63 ) } }` ) ;
23
+ }
20
24
21
- if ( isSemverGroup && mismatches . length > 0 ) {
22
- console . log ( chalk `{dim = Semver Group ${ i } ${ '=' . repeat ( 63 ) } }` ) ;
23
- }
24
-
25
- mismatches . forEach ( ( { dependencyType, name, version, wrapper } ) => {
26
- console . log (
27
- chalk `{red ✕ ${ name } } {red.dim ${ version } in ${ dependencyType } of ${
28
- wrapper . contents . name
29
- } should be ${ setSemverRange ( semverGroup . range , version ) } }`,
30
- ) ;
31
- } ) ;
25
+ mismatches . forEach ( ( { dependencyType, name, version, wrapper } ) => {
26
+ console . log (
27
+ chalk `{red ✕ ${ name } } {red.dim ${ version } in ${ dependencyType } of ${
28
+ wrapper . contents . name
29
+ } should be ${ setSemverRange ( semverGroup . range , version ) } }`,
30
+ ) ;
31
+ } ) ;
32
32
33
- if ( mismatches . length > 0 ) {
34
- isInvalid = true ;
33
+ if ( mismatches . length > 0 ) {
34
+ isInvalid = true ;
35
+ }
35
36
}
36
37
} ) ;
37
38
0 commit comments