(actualFilePath: string, expectedFilePath: string)
| 2 | import { wrappedFs as fs } from '../../src/wrapped-fs.js'; |
| 3 | |
| 4 | export async function compFiles(actualFilePath: string, expectedFilePath: string): Promise<void> { |
| 5 | if (process.env.ELECTRON_ASAR_SPEC_UPDATE) { |
| 6 | await fs.writeFile(expectedFilePath, await fs.readFile(actualFilePath)); |
| 7 | } |
| 8 | const [actualFileContent, expectedFileContent] = await Promise.all([ |
| 9 | fs.readFile(actualFilePath, 'utf8'), |
| 10 | fs.readFile(expectedFilePath, 'utf8'), |
| 11 | ]); |
| 12 | expect(actualFileContent).toBe(expectedFileContent); |
| 13 | |
| 14 | const [actualIsSymlink, expectedIsSymlink] = [ |
| 15 | isSymbolicLinkSync(actualFilePath), |
| 16 | isSymbolicLinkSync(expectedFilePath), |
| 17 | ]; |
| 18 | expect(actualIsSymlink).toBe(expectedIsSymlink); |
| 19 | |
| 20 | if (actualIsSymlink && expectedIsSymlink) { |
| 21 | const [actualSymlinkPointer, expectedSymlinkPointer] = [ |
| 22 | fs.readlinkSync(actualFilePath), |
| 23 | fs.readlinkSync(expectedFilePath), |
| 24 | ]; |
| 25 | expect(actualSymlinkPointer).toBe(expectedSymlinkPointer); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | export function isSymbolicLinkSync(path: string): boolean { |
| 30 | const stats = fs.lstatSync(path); |
no test coverage detected
searching dependent graphs…