1
0
mirror of https://github.com/jiahaog/Nativefier synced 2024-06-21 07:06:35 +02:00
Nativefier/src/helpers/upgrade/rceditGet.ts
Adam Weeden 9330c8434f
Add an option to upgrade an existing app (fix #1131) (PR #1138)
This adds a `--upgrade` option to upgrade-in-place an old app, re-using its options it can.
Should help fix #1131

Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
2021-04-28 22:00:31 -04:00

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 {
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;
}
}