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
Prev Previous commit
Next Next commit
Remove async
confused-Techie authored Jul 21, 2023

Unverified

This user has not yet uploaded their public signing key.
commit 57a12ddc48b55787908da1c754dbbcc6306a4514
8 changes: 4 additions & 4 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/promises');
const fs = require('fs');
const path = require('path');

// Handles requests with 'atom' protocol.
@@ -30,20 +30,20 @@ module.exports = class AtomProtocolHandler {

// Creates the 'atom' custom protocol handler.
registerAtomProtocol() {
protocol.registerFileProtocol('atom', async (request, callback) => {
protocol.registerFileProtocol('atom', (request, callback) => {
const relativePath = path.normalize(request.url.substr(7));

let filePath;
if (relativePath.indexOf('assets/') === 0) {
const assetsPath = path.join(process.env.ATOM_HOME, relativePath);
const stat = await fs.stat(assetsPath).catch( () => false );
const stat = fs.statSync(assetsPath).catch( () => false );
if (stat && stat.isFile()) filePath = assetsPath;
}

if (!filePath) {
for (let loadPath of this.loadPaths) {
filePath = path.join(loadPath, relativePath);
const stat = await fs.stat(filePath).catch( () => false );
const stat = fs.statSync(filePath).catch( () => false );
if (stat && stat.isFile()) break;
}
}