mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-06-01 12:20:48 +00:00
7a08a2d676
* Catch promise errors better * Move subFunctions to bottom of createNewWindow * Use parents when creating child BrowserWindow instances * Some about:blank pages have an anchor (for some reason) * Inject browserWindowOptions better * Interim refactor to MainWindow object * Split up the window functions/helpers/events some * Further separate out window functions + tests * Add a mock for unit testing functions that access electron * Add unit tests for onWillPreventUnload * Improve windowEvents tests * Add the first test for windowHelpers * Move WebRequest event handling to node * insertCSS completely under test * clearAppData completely under test * Fix contextMenu require bug * More tests + fixes * Fix + add to createNewTab tests * Convert createMainWindow back to func + work out gremlins * Move setupWindow away from main since its shared * Make sure contextMenu is handling promises * Fix issues with fullscreen not working + menu refactor * Run jest against app/dist so that we can hit app unit tests as well * Requested PR changes * Add strict typing; tests currently failing * Fix failing unit tests * Add some more eslint warnings and fixes * More eslint fixes * Strict typing on (still issues with the lib dir) * Fix the package.json import/require * Fix some funky test errors * Warn -> Error for eslint rules * @ts-ignore -> @ts-expect-error * Add back the ext code I removed
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import * as os from 'os';
|
|
import * as path from 'path';
|
|
import { spawnSync } from 'child_process';
|
|
|
|
// A modification of https://github.com/electron/node-rcedit to support the retrieval
|
|
// of information.
|
|
|
|
export function getVersionString(
|
|
executablePath: string,
|
|
versionString: string,
|
|
): string | undefined {
|
|
let rcedit = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'..',
|
|
'node_modules',
|
|
'rcedit',
|
|
'bin',
|
|
process.arch === 'x64' ? 'rcedit-x64.exe' : 'rcedit.exe',
|
|
);
|
|
const args = [executablePath, `--get-version-string`, versionString];
|
|
|
|
const spawnOptions = {
|
|
env: { ...process.env },
|
|
};
|
|
|
|
// Use Wine on non-Windows platforms except for WSL, which doesn't need it
|
|
if (process.platform !== 'win32' && !os.release().endsWith('Microsoft')) {
|
|
args.unshift(rcedit);
|
|
rcedit = process.arch === 'x64' ? 'wine64' : 'wine';
|
|
// Suppress "fixme:" stderr log messages
|
|
spawnOptions.env.WINEDEBUG = '-all';
|
|
}
|
|
try {
|
|
const child = spawnSync(rcedit, args, spawnOptions);
|
|
const result = child.output?.toString().split(',wine: ')[0];
|
|
return result.startsWith(',') ? result.substr(1) : result;
|
|
} catch {
|
|
return undefined;
|
|
}
|
|
}
|