[RetainAsar] Initial Add

This commit is contained in:
Ducko 2021-12-11 15:20:28 +00:00
parent c90c4fe491
commit d289cec12e
2 changed files with 31 additions and 2 deletions

View File

@ -1,6 +1,11 @@
// Stub for now at least
// Stub for now at least, also retaining OpenAsar
const retainAsar = require('./retainAsar');
exports.install = (callback) => { callback(); };
exports.update = (callback) => { callback(); };
exports.update = (callback) => {
retainAsar();
callback();
};
exports.uninstall = (callback) => { callback(); };
exports.isInstalled = (callback) => { callback(true); }; // Stub to true or false?

View File

@ -0,0 +1,24 @@
const paths = require('../paths');
const { join } = require('path');
const { copyFileSync, readdirSync } = require('original-fs'); // Use original-fs, not Electron's modified fs
module.exports = () => {
log('RetainAsar', 'Detected possible host update, retaining OpenAsar...');
const currentAsarPath = join(require.main.filename, '..');
const installDir = paths.getInstallPath();
const nextAppDir = readdirSync(installDir).reverse().find((x) => x.startsWith('app-1'));
const nextAsarPath = join(installDir, nextAppDir, 'resources', 'app.asar');
log('RetainAsar', `Paths:
Install Dir: ${installDir}
Next App Dir: ${nextAppDir}
Current Asar: ${currentAsarPath}
Next Asar: ${nextAsarPath}`);
copyFileSync(currentAsarPath, nextAsarPath);
log('RetainAsar', 'Completed');
};