2023-06-22 17:21:42 +03:00
|
|
|
const fs = require('node:fs');
|
|
|
|
const path = require('node:path');
|
2020-06-17 00:19:57 +03:00
|
|
|
|
|
|
|
const utils = require('./lib/utils');
|
2022-09-14 00:13:40 +03:00
|
|
|
const branding = require('../shell/app/BRANDING.json');
|
2020-06-17 00:19:57 +03:00
|
|
|
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
console.log('Not checking symlinks on non-darwin platform');
|
|
|
|
process.exit(0);
|
|
|
|
}
|
|
|
|
|
2022-09-14 00:13:40 +03:00
|
|
|
const appPath = path.resolve(__dirname, '..', '..', 'out', utils.getOutDir(), `${branding.product_name}.app`);
|
2020-06-17 00:19:57 +03:00
|
|
|
const visited = new Set();
|
|
|
|
const traverse = (p) => {
|
|
|
|
if (visited.has(p)) return;
|
|
|
|
|
|
|
|
visited.add(p);
|
|
|
|
if (!fs.statSync(p).isDirectory()) return;
|
|
|
|
|
|
|
|
for (const child of fs.readdirSync(p)) {
|
|
|
|
const childPath = path.resolve(p, child);
|
|
|
|
let realPath;
|
|
|
|
try {
|
|
|
|
realPath = fs.realpathSync(childPath);
|
|
|
|
} catch (err) {
|
|
|
|
if (err.path) {
|
|
|
|
console.error('Detected an invalid symlink');
|
|
|
|
console.error('Source:', childPath);
|
|
|
|
let link = fs.readlinkSync(childPath);
|
|
|
|
if (!link.startsWith('.')) {
|
|
|
|
link = `../${link}`;
|
|
|
|
}
|
|
|
|
console.error('Target:', path.resolve(childPath, link));
|
|
|
|
process.exit(1);
|
|
|
|
} else {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
traverse(realPath);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
traverse(appPath);
|