File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,9 @@ export function readFile(
7575 | string
7676 | {
7777 encoding ? : string | null ,
78- // Ignored :
79- flag ? : string ,
80- signal ? : mixed ,
78+ // Unsupported :
79+ flag ? : string , // Doesn't make sense except "r"
80+ signal ? : mixed , // We'll have our own signal
8181 } ,
8282): string | Buffer {
8383 const map = unstable_getCacheForType ( createReadFileCache ) ;
@@ -91,7 +91,21 @@ export function readFile(
9191 if ( ! options ) {
9292 return result ;
9393 }
94- const encoding = typeof options === 'string' ? options : options . encoding ;
94+ let encoding ;
95+ if ( typeof options === 'string' ) {
96+ encoding = options ;
97+ } else {
98+ const flag = options . flag ;
99+ if ( flag != null && flag !== 'r' ) {
100+ throw Error (
101+ 'The flag option is not supported, and always defaults to "r".' ,
102+ ) ;
103+ }
104+ if ( options . signal ) {
105+ throw Error ( 'The signal option is not supported.' ) ;
106+ }
107+ encoding = options . encoding ;
108+ }
95109 if ( typeof encoding !== 'string' ) {
96110 return result ;
97111 }
You can’t perform that action at this time.
0 commit comments