Merge pull request #170 from Sertonix/atom-protocol-handler-async

Remove `fs-plus` from atom-protocol-handler
This commit is contained in:
confused_techie 2023-09-03 21:49:47 -07:00 committed by GitHub
commit b39983e5a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
const { protocol } = require('electron');
const fs = require('fs-plus');
const fs = require('fs');
const path = require('path');
// Handles requests with 'atom' protocol.
@ -36,15 +36,19 @@ module.exports = class AtomProtocolHandler {
let filePath;
if (relativePath.indexOf('assets/') === 0) {
const assetsPath = path.join(process.env.ATOM_HOME, relativePath);
const stat = fs.statSyncNoException(assetsPath);
if (stat && stat.isFile()) filePath = assetsPath;
try {
const stat = fs.statSync(assetsPath);
if (stat && stat.isFile()) filePath = assetsPath;
} catch (e) {}
}
if (!filePath) {
for (let loadPath of this.loadPaths) {
filePath = path.join(loadPath, relativePath);
const stat = fs.statSyncNoException(filePath);
if (stat && stat.isFile()) break;
try {
const stat = fs.statSync(filePath);
if (stat && stat.isFile()) break;
} catch (e) {}
}
}