mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-25 12:55:18 -07:00
9fe13601fb
- Add `launchAppBackgroundDetached` that spawns with `--start --background` and `SUBMINER_BACKGROUND_CHILD=1` - On darwin with empty appArgs, use detached background launch instead of inherited process - Add `extraEnv` param to `launchAppCommandDetached` for env injection - Inject deps into `runAppPassthroughCommand` for testability - Bump vendor/subminer-yomitan submodule
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import {
|
|
launchAppBackgroundDetached,
|
|
launchTexthookerOnly,
|
|
runAppCommandWithInherit,
|
|
} from '../mpv.js';
|
|
import type { LauncherCommandContext } from './context.js';
|
|
|
|
type AppCommandDeps = {
|
|
platform: () => NodeJS.Platform;
|
|
runAppCommandWithInherit: (appPath: string, appArgs: string[]) => void;
|
|
launchAppBackgroundDetached: (
|
|
appPath: string,
|
|
logLevel: LauncherCommandContext['args']['logLevel'],
|
|
) => void;
|
|
};
|
|
|
|
const defaultAppCommandDeps: AppCommandDeps = {
|
|
platform: () => process.platform,
|
|
runAppCommandWithInherit,
|
|
launchAppBackgroundDetached,
|
|
};
|
|
|
|
export function runAppPassthroughCommand(
|
|
context: LauncherCommandContext,
|
|
deps: AppCommandDeps = defaultAppCommandDeps,
|
|
): boolean {
|
|
const { args, appPath } = context;
|
|
if (!appPath) {
|
|
return false;
|
|
}
|
|
if (args.settings) {
|
|
deps.runAppCommandWithInherit(appPath, ['--settings']);
|
|
return true;
|
|
}
|
|
if (!args.appPassthrough) {
|
|
return false;
|
|
}
|
|
if (deps.platform() === 'darwin' && args.appArgs.length === 0) {
|
|
deps.launchAppBackgroundDetached(appPath, args.logLevel);
|
|
return true;
|
|
}
|
|
deps.runAppCommandWithInherit(appPath, args.appArgs);
|
|
return true;
|
|
}
|
|
|
|
export function runTexthookerCommand(context: LauncherCommandContext): boolean {
|
|
const { args, appPath } = context;
|
|
if (!args.texthookerOnly || !appPath) {
|
|
return false;
|
|
}
|
|
launchTexthookerOnly(appPath, args);
|
|
return true;
|
|
}
|