2024-09-10 04:21:22 +03:00
|
|
|
'use strict';
|
2019-02-19 00:22:45 +03:00
|
|
|
|
2024-09-10 04:21:22 +03:00
|
|
|
const assert = require('assert');
|
|
|
|
const fs = require('../../lib/wrapped-fs').default;
|
2016-12-04 20:59:34 +03:00
|
|
|
|
2019-04-27 07:14:01 +03:00
|
|
|
module.exports = async function (actualFilePath, expectedFilePath) {
|
2021-09-09 21:06:13 +03:00
|
|
|
if (process.env.ELECTRON_ASAR_SPEC_UPDATE) {
|
2024-09-10 04:21:22 +03:00
|
|
|
await fs.writeFile(expectedFilePath, await fs.readFile(actualFilePath));
|
2021-09-09 21:06:13 +03:00
|
|
|
}
|
2024-09-10 04:21:22 +03:00
|
|
|
const [actualFileContent, expectedFileContent] = await Promise.all([
|
|
|
|
fs.readFile(actualFilePath, 'utf8'),
|
|
|
|
fs.readFile(expectedFilePath, 'utf8'),
|
|
|
|
]);
|
|
|
|
assert.strictEqual(actualFileContent, expectedFileContent);
|
2024-03-06 02:47:13 +03:00
|
|
|
|
2024-09-10 04:21:22 +03:00
|
|
|
const [actualIsSymlink, expectedIsSymlink] = [
|
|
|
|
isSymbolicLinkSync(actualFilePath),
|
|
|
|
isSymbolicLinkSync(expectedFilePath),
|
|
|
|
];
|
|
|
|
assert.strictEqual(actualIsSymlink, expectedIsSymlink);
|
2024-03-06 02:47:13 +03:00
|
|
|
|
|
|
|
if (actualIsSymlink && expectedIsSymlink) {
|
2024-09-10 04:21:22 +03:00
|
|
|
const [actualSymlinkPointer, expectedSymlinkPointer] = [
|
|
|
|
fs.readlinkSync(actualFilePath),
|
|
|
|
fs.readlinkSync(expectedFilePath),
|
|
|
|
];
|
|
|
|
assert.strictEqual(actualSymlinkPointer, expectedSymlinkPointer);
|
2024-03-06 02:47:13 +03:00
|
|
|
}
|
2024-09-10 04:21:22 +03:00
|
|
|
};
|
2024-03-06 02:47:13 +03:00
|
|
|
|
2024-09-10 04:21:22 +03:00
|
|
|
function isSymbolicLinkSync(path) {
|
|
|
|
const stats = fs.lstatSync(path);
|
|
|
|
return stats.isSymbolicLink();
|
2016-12-29 00:45:36 +03:00
|
|
|
}
|