(
filePath: string,
options: BufferEncoding | { encoding?: BufferEncoding } = {},
)
| 86 | } |
| 87 | |
| 88 | async readFile( |
| 89 | filePath: string, |
| 90 | options: BufferEncoding | { encoding?: BufferEncoding } = {}, |
| 91 | ) { |
| 92 | filePath = path.normalize(filePath); |
| 93 | |
| 94 | if (typeof options === 'string') { |
| 95 | options = { |
| 96 | encoding: options, |
| 97 | }; |
| 98 | } |
| 99 | |
| 100 | const encoding = options ? options.encoding : null; |
| 101 | |
| 102 | const entry = this._assertFile(filePath); |
| 103 | |
| 104 | const raw = Buffer.from(entry.contents, 'base64'); |
| 105 | |
| 106 | if (encoding) { |
| 107 | return raw.toString(encoding); |
| 108 | } else { |
| 109 | return raw; |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | async writeFile( |
| 114 | filePath: string, |
no test coverage detected