Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove fs-plus from atom-protocol-handler #170

Merged
18 changes: 13 additions & 5 deletions src/main-process/atom-protocol-handler.js
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -36,15 +36,23 @@ 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) {
return false;
}
}
confused-Techie marked this conversation as resolved.
Show resolved Hide resolved

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) {
return false;
confused-Techie marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

Expand Down