Add a command to start the Electron app

This commit is contained in:
Samuel Elliott
2022-04-05 20:48:26 +01:00
parent 3c66bbd95d
commit b677b22809
4 changed files with 40 additions and 2 deletions

31
src/cli/app.ts Normal file
View File

@@ -0,0 +1,31 @@
import { createRequire } from 'module';
import { execFileSync } from 'child_process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../cli.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../util.js';
const debug = createDebug('cli:app');
export const command = 'app';
export const desc = 'Start the Electron app';
export function builder(yargs: Argv<ParentArguments>) {
return yargs;
}
type Arguments = YargsArguments<ReturnType<typeof builder>>;
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const require = createRequire(import.meta.url);
const electron = require('electron');
if (typeof electron !== 'string') {
throw new Error('Already running in Electron??');
}
execFileSync(electron, [
'dist/app/main/app-entry.cjs',
], {
stdio: 'inherit',
});
}

View File

@@ -3,3 +3,4 @@ export * as nso from './nso.js';
export * as splatnet2 from './splatnet2.js';
export * as pctl from './pctl.js';
export * as androidZncaApiServerFrida from './android-znca-api-server-frida.js';
export * as app from './app.js';