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 99 " perf" ,
1010 " refactor" ,
1111 " 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"
2214 ]
2315}
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const fs = require('fs');
2121const path = require ( 'path' ) ;
2222const configPath = path . resolve ( __dirname , './commit-message.json' ) ;
2323const config = JSON . parse ( fs . readFileSync ( configPath , 'utf8' ) ) ;
24+ const { packages, tools } = require ( '../../lib/packages' ) ;
2425const PATTERN = / ^ ( r e v e r t \: ) ? ( \w + ) (?: \( ( [ ^ ) ] + ) \) ) ? \: ( .+ ) $ / ;
2526
2627module . exports = function ( commitSubject ) {
@@ -45,14 +46,27 @@ module.exports = function(commitSubject) {
4546 }
4647
4748 const scope = match [ 3 ] ;
49+ const allScopes = Object . keys ( packages ) . concat ( Object . keys ( tools ) ) ;
4850
49- if ( scope && ! config [ 'scopes' ] . includes ( scope ) ) {
51+ if ( scope && ! allScopes . includes ( scope ) ) {
5052 error (
5153 `"${ scope } " is not an allowed scope.\n => SCOPES: ${ config [ 'scopes' ] . join ( ', ' ) } ` ,
5254 commitSubject ) ;
5355 return false ;
5456 }
5557
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+
5670 return true ;
5771} ;
5872
You can’t perform that action at this time.
0 commit comments