( snapshotData: SnapshotData, snapshotPath: string, )
| 180 | string.replaceAll(/\r\n|\r/g, '\n'); |
| 181 | |
| 182 | export const saveSnapshotFile = ( |
| 183 | snapshotData: SnapshotData, |
| 184 | snapshotPath: string, |
| 185 | ): void => { |
| 186 | const snapshots = Object.keys(snapshotData) |
| 187 | .sort(naturalCompare) |
| 188 | .map( |
| 189 | key => |
| 190 | `exports[${printBacktickString(key)}] = ${printBacktickString( |
| 191 | normalizeNewlines(snapshotData[key]), |
| 192 | )};`, |
| 193 | ); |
| 194 | |
| 195 | ensureDirectoryExists(snapshotPath); |
| 196 | fs.writeFileSync( |
| 197 | snapshotPath, |
| 198 | `${writeSnapshotVersion()}\n\n${snapshots.join('\n\n')}\n`, |
| 199 | ); |
| 200 | }; |
no test coverage detected