@@ -29,15 +29,17 @@ function check(file, updateGolden = false) {
2929
3030 // Load the golden file for comparison
3131 const golden = path . posix . join ( path . dirname ( __filename ) , 'golden' , file + '.golden' ) ;
32- const goldenContents = fs . readFileSync ( golden , { encoding : 'utf-8' } ) . replace ( / \r \n / g, '\n' ) ;
3332
34- // Check if actualContents matches golden file
35- if ( actualContents !== goldenContents ) {
36- if ( updateGolden ) {
37- // Write to golden file
38- fs . writeFileSync ( golden , actualContents ) ;
39- console . error ( `Replaced ${ path . join ( process . cwd ( ) , golden ) } ` ) ;
40- } else {
33+ if ( updateGolden ) {
34+ // Write to golden file
35+ // TODO(kyliau): Consider calling mkdirp() here, otherwise write operation
36+ // would fail if directory does not already exist.
37+ fs . writeFileSync ( golden , actualContents ) ;
38+ console . error ( `Replaced ${ path . join ( process . cwd ( ) , golden ) } ` ) ;
39+ } else {
40+ const goldenContents = fs . readFileSync ( golden , { encoding : 'utf-8' } ) . replace ( / \r \n / g, '\n' ) ;
41+ // Check if actualContents matches golden file
42+ if ( actualContents !== goldenContents ) {
4143 // Generated does not match golden
4244 const diff = unidiff . diffLines ( goldenContents , actualContents ) ;
4345 const prettyDiff = unidiff . formatLines ( diff ) ;
@@ -58,21 +60,27 @@ module.exports = {
5860 check,
5961 files : [
6062 'BUILD.bazel' ,
63+ '@angular/core/BUILD.bazel' ,
6164 '@gregmagolan/BUILD.bazel' ,
62- '@gregmagolan/test-a/BUILD.bazel' ,
6365 '@gregmagolan/test-a/bin/BUILD.bazel' ,
64- '@gregmagolan/test-b /BUILD.bazel' ,
66+ '@gregmagolan/test-a /BUILD.bazel' ,
6567 '@gregmagolan/test-b/bin/BUILD.bazel' ,
68+ '@gregmagolan/test-b/BUILD.bazel' ,
6669 'ajv/BUILD.bazel' ,
67- 'jasmine/BUILD.bazel' ,
6870 'jasmine/bin/BUILD.bazel' ,
69- 'unidiff/BUILD.bazel' ,
71+ 'jasmine/BUILD.bazel' ,
72+ 'rxjs/BUILD.bazel' ,
7073 'unidiff/bin/BUILD.bazel' ,
74+ 'unidiff/BUILD.bazel' ,
75+ 'zone.js/BUILD.bazel' ,
76+ 'node_modules/@angular/core/BUILD.bazel' ,
7177 'node_modules/@gregmagolan/BUILD.bazel' ,
7278 'node_modules/@gregmagolan/test-a/BUILD.bazel' ,
7379 'node_modules/@gregmagolan/test-b/BUILD.bazel' ,
7480 'node_modules/ajv/BUILD.bazel' ,
7581 'node_modules/jasmine/BUILD.bazel' ,
82+ 'node_modules/rxjs/BUILD.bazel' ,
7683 'node_modules/unidiff/BUILD.bazel' ,
84+ 'node_modules/zone.js/BUILD.bazel' ,
7785 ] ,
78- } ;
86+ } ;
0 commit comments