@@ -77,6 +77,30 @@ function overwriteMainAndIndex(options: Schema) {
77
77
} ;
78
78
}
79
79
80
+ function overwriteGitignore ( options : Schema ) {
81
+ return ( host : Tree ) => {
82
+ const gitignore = `${ options . name } /.gitignore` ;
83
+ if ( ! host . exists ( gitignore ) ) {
84
+ return host ;
85
+ }
86
+ const gitIgnoreContent = host . read ( gitignore ) ;
87
+ if ( ! gitIgnoreContent ) {
88
+ throw new Error ( 'Failed to read .gitignore content' ) ;
89
+ }
90
+
91
+ if ( gitIgnoreContent . includes ( '/bazel-out\n' ) ) {
92
+ return host ;
93
+ }
94
+ const lines = gitIgnoreContent . toString ( ) . split ( / \n / g) ;
95
+ const recorder = host . beginUpdate ( gitignore ) ;
96
+ const compileOutput = lines . findIndex ( ( line : string ) => line === '# compiled output' ) ;
97
+ recorder . insertRight ( compileOutput , '\n/bazel-out' ) ;
98
+ host . commitUpdate ( recorder ) ;
99
+
100
+ return host ;
101
+ } ;
102
+ }
103
+
80
104
function replacePropertyInAstObject (
81
105
recorder : UpdateRecorder , node : JsonAstObject , propertyName : string , value : JsonValue ,
82
106
indent : number ) {
@@ -176,6 +200,7 @@ export default function(options: Schema): Rule {
176
200
addDevDependenciesToPackageJson ( options ) ,
177
201
schematic ( 'bazel-workspace' , options ) ,
178
202
overwriteMainAndIndex ( options ) ,
203
+ overwriteGitignore ( options ) ,
179
204
updateWorkspaceFileToUseBazelBuilder ( options ) ,
180
205
] ) ;
181
206
} ;
0 commit comments