File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed
scripts/validate-commit-message Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change 9
9
" perf" ,
10
10
" refactor" ,
11
11
" style" ,
12
- " test"
13
- ],
14
- "scopes" : [
15
- " @angular/cli" ,
16
- " @ngtools/json-schema" ,
17
- " @ngtools/logger" ,
18
- " @ngtools/webpack" ,
19
-
20
- " packaging" ,
21
- " changelog"
12
+ " test" ,
13
+ " tool"
22
14
]
23
15
}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const fs = require('fs');
21
21
const path = require ( 'path' ) ;
22
22
const configPath = path . resolve ( __dirname , './commit-message.json' ) ;
23
23
const config = JSON . parse ( fs . readFileSync ( configPath , 'utf8' ) ) ;
24
+ const { packages, tools } = require ( '../../lib/packages' ) ;
24
25
const PATTERN = / ^ ( r e v e r t \: ) ? ( \w + ) (?: \( ( [ ^ ) ] + ) \) ) ? \: ( .+ ) $ / ;
25
26
26
27
module . exports = function ( commitSubject ) {
@@ -45,14 +46,27 @@ module.exports = function(commitSubject) {
45
46
}
46
47
47
48
const scope = match [ 3 ] ;
49
+ const allScopes = Object . keys ( packages ) . concat ( Object . keys ( tools ) ) ;
48
50
49
- if ( scope && ! config [ 'scopes' ] . includes ( scope ) ) {
51
+ if ( scope && ! allScopes . includes ( scope ) ) {
50
52
error (
51
53
`"${ scope } " is not an allowed scope.\n => SCOPES: ${ config [ 'scopes' ] . join ( ', ' ) } ` ,
52
54
commitSubject ) ;
53
55
return false ;
54
56
}
55
57
58
+ // Having a tool scope and not using tool() is an error.
59
+ if ( scope && Object . keys ( tools ) . includes ( scope ) && type !== 'tool' ) {
60
+ error ( `"${ scope } " is a tool, but the type is NOT "tool".` ) ;
61
+ return false ;
62
+ }
63
+
64
+ // Having a package scope and using tool() is an error.
65
+ if ( scope && Object . keys ( tools ) . includes ( scope ) && type !== 'tool' ) {
66
+ error ( `"${ scope } " is NOT a tool, but the type is "tool".` ) ;
67
+ return false ;
68
+ }
69
+
56
70
return true ;
57
71
} ;
58
72
You can’t perform that action at this time.
0 commit comments