File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
angular_devkit/build_angular/src/utils/index-file
schematics/angular/migrations/update-17 Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change 66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- import * as fs from 'fs ' ;
10- import { join } from 'path' ;
9+ import { readFile } from 'node:fs/promises ' ;
10+ import { join } from 'node: path' ;
1111import { NormalizedCachedOptions } from '../normalize-cache' ;
1212import { NormalizedOptimizationOptions } from '../normalize-optimization' ;
1313import { stripBom } from '../strip-bom' ;
@@ -104,11 +104,19 @@ export class IndexHtmlGenerator {
104104 }
105105
106106 async readAsset ( path : string ) : Promise < string > {
107- return fs . promises . readFile ( path , 'utf-8' ) ;
107+ try {
108+ return await readFile ( path , 'utf-8' ) ;
109+ } catch {
110+ throw new Error ( `Failed to read asset "${ path } ".` ) ;
111+ }
108112 }
109113
110114 protected async readIndex ( path : string ) : Promise < string > {
111- return fs . promises . readFile ( path , 'utf-8' ) ;
115+ try {
116+ return await readFile ( path , 'utf-8' ) ;
117+ } catch {
118+ throw new Error ( `Failed to read index HTML file "${ path } ".` ) ;
119+ }
112120 }
113121}
114122
Original file line number Diff line number Diff line change @@ -57,6 +57,10 @@ export default function (): Rule {
5757 continue ;
5858 }
5959
60+ if ( options [ 'index' ] === '' ) {
61+ options [ 'index' ] = false ;
62+ }
63+
6064 // Rename and transform options
6165 options [ 'browser' ] = options [ 'main' ] ;
6266 if ( hasServerTarget && typeof options [ 'browser' ] === 'string' ) {
You can’t perform that action at this time.
0 commit comments