mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-02 06:22:42 -08:00
fix(ci): restore launcher app capture helper export
This commit is contained in:
@@ -5,7 +5,7 @@ import path from 'node:path';
|
||||
import net from 'node:net';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import type { Args } from './types';
|
||||
import { startOverlay, state, waitForUnixSocketReady } from './mpv';
|
||||
import { runAppCommandCaptureOutput, startOverlay, state, waitForUnixSocketReady } from './mpv';
|
||||
import * as mpvModule from './mpv';
|
||||
|
||||
function createTempSocketPath(): { dir: string; socketPath: string } {
|
||||
@@ -19,6 +19,18 @@ test('mpv module exposes only canonical socket readiness helper', () => {
|
||||
assert.equal('waitForSocket' in mpvModule, false);
|
||||
});
|
||||
|
||||
test('runAppCommandCaptureOutput captures status and stdio', () => {
|
||||
const result = runAppCommandCaptureOutput(process.execPath, [
|
||||
'-e',
|
||||
'process.stdout.write("stdout-line"); process.stderr.write("stderr-line");',
|
||||
]);
|
||||
|
||||
assert.equal(result.status, 0);
|
||||
assert.equal(result.stdout, 'stdout-line');
|
||||
assert.equal(result.stderr, 'stderr-line');
|
||||
assert.equal(result.error, undefined);
|
||||
});
|
||||
|
||||
test('waitForUnixSocketReady returns false when socket never appears', async () => {
|
||||
const { dir, socketPath } = createTempSocketPath();
|
||||
try {
|
||||
|
||||
@@ -658,6 +658,28 @@ export function runAppCommandWithInherit(appPath: string, appArgs: string[]): ne
|
||||
process.exit(result.status ?? 0);
|
||||
}
|
||||
|
||||
export function runAppCommandCaptureOutput(
|
||||
appPath: string,
|
||||
appArgs: string[],
|
||||
): {
|
||||
status: number;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
error?: Error;
|
||||
} {
|
||||
const result = spawnSync(appPath, appArgs, {
|
||||
env: buildAppEnv(),
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
return {
|
||||
status: result.status ?? 1,
|
||||
stdout: result.stdout ?? '',
|
||||
stderr: result.stderr ?? '',
|
||||
error: result.error ?? undefined,
|
||||
};
|
||||
}
|
||||
|
||||
export function runAppCommandWithInheritLogged(
|
||||
appPath: string,
|
||||
appArgs: string[],
|
||||
|
||||
Reference in New Issue
Block a user