(file: string, text: string)
| 94 | * to be a regular file. |
| 95 | */ |
| 96 | export function writeRegularFileSync(file: string, text: string): void { |
| 97 | const fd = fs.openSync(file, fs.constants.O_WRONLY | fs.constants.O_CREAT | (fs.constants.O_NONBLOCK ?? 0), 0o666); |
| 98 | try { |
| 99 | if (!fs.fstatSync(fd).isFile()) throw notRegularFile(file); |
| 100 | fs.ftruncateSync(fd, 0); |
| 101 | fs.writeFileSync(fd, text, 'utf-8'); |
| 102 | } finally { |
| 103 | fs.closeSync(fd); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * The longest run of name characters a pattern is given as written. No name, |
no test coverage detected