mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 06:22:44 -08:00
run prettier
This commit is contained in:
@@ -62,7 +62,7 @@ test('inferAniSkipMetadataForFile falls back to anime directory title when filen
|
||||
|
||||
test('buildSubminerScriptOpts includes aniskip metadata fields', () => {
|
||||
const opts = buildSubminerScriptOpts('/tmp/SubMiner.AppImage', '/tmp/subminer.sock', {
|
||||
title: 'Frieren: Beyond Journey\'s End',
|
||||
title: "Frieren: Beyond Journey's End",
|
||||
season: 1,
|
||||
episode: 5,
|
||||
source: 'guessit',
|
||||
|
||||
@@ -28,7 +28,11 @@ function toPositiveInt(value: unknown): number | null {
|
||||
}
|
||||
|
||||
function detectEpisodeFromName(baseName: string): number | null {
|
||||
const patterns = [/[Ss]\d+[Ee](\d{1,3})/, /(?:^|[\s._-])[Ee][Pp]?[\s._-]*(\d{1,3})(?:$|[\s._-])/, /[-\s](\d{1,3})$/];
|
||||
const patterns = [
|
||||
/[Ss]\d+[Ee](\d{1,3})/,
|
||||
/(?:^|[\s._-])[Ee][Pp]?[\s._-]*(\d{1,3})(?:$|[\s._-])/,
|
||||
/[-\s](\d{1,3})$/,
|
||||
];
|
||||
for (const pattern of patterns) {
|
||||
const match = baseName.match(pattern);
|
||||
if (!match || !match[1]) continue;
|
||||
@@ -171,7 +175,11 @@ export function inferAniSkipMetadataForFile(
|
||||
}
|
||||
|
||||
function sanitizeScriptOptValue(value: string): string {
|
||||
return value.replace(/,/g, ' ').replace(/[\r\n]/g, ' ').replace(/\s+/g, ' ').trim();
|
||||
return value
|
||||
.replace(/,/g, ' ')
|
||||
.replace(/[\r\n]/g, ' ')
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
export function buildSubminerScriptOpts(
|
||||
|
||||
@@ -4,11 +4,9 @@ import { execFileSync } from 'node:child_process';
|
||||
import path from 'node:path';
|
||||
|
||||
test('launcher root help lists subcommands', () => {
|
||||
const output = execFileSync(
|
||||
'bun',
|
||||
['run', path.join(process.cwd(), 'launcher/main.ts'), '-h'],
|
||||
{ encoding: 'utf8' },
|
||||
);
|
||||
const output = execFileSync('bun', ['run', path.join(process.cwd(), 'launcher/main.ts'), '-h'], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
|
||||
assert.match(output, /Commands:/);
|
||||
assert.match(output, /jellyfin\|jf/);
|
||||
|
||||
@@ -182,7 +182,8 @@ export function parseCliPrograms(
|
||||
server: typeof options.server === 'string' ? options.server : undefined,
|
||||
username: typeof options.username === 'string' ? options.username : undefined,
|
||||
password: typeof options.password === 'string' ? options.password : undefined,
|
||||
passwordStore: typeof options.passwordStore === 'string' ? options.passwordStore : undefined,
|
||||
passwordStore:
|
||||
typeof options.passwordStore === 'string' ? options.passwordStore : undefined,
|
||||
logLevel: typeof options.logLevel === 'string' ? options.logLevel : undefined,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -22,10 +22,14 @@ function withTempDir<T>(fn: (dir: string) => T): T {
|
||||
}
|
||||
|
||||
function runLauncher(argv: string[], env: NodeJS.ProcessEnv): RunResult {
|
||||
const result = spawnSync(process.execPath, ['run', path.join(process.cwd(), 'launcher/main.ts'), ...argv], {
|
||||
env,
|
||||
encoding: 'utf8',
|
||||
});
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
['run', path.join(process.cwd(), 'launcher/main.ts'), ...argv],
|
||||
{
|
||||
env,
|
||||
encoding: 'utf8',
|
||||
},
|
||||
);
|
||||
return {
|
||||
status: result.status,
|
||||
stdout: result.stdout || '',
|
||||
@@ -225,10 +229,7 @@ test('jellyfin setup forwards password-store to app command', () => {
|
||||
SUBMINER_APPIMAGE_PATH: appPath,
|
||||
SUBMINER_TEST_CAPTURE: capturePath,
|
||||
};
|
||||
const result = runLauncher(
|
||||
['jf', 'setup', '--password-store', 'gnome-libsecret'],
|
||||
env,
|
||||
);
|
||||
const result = runLauncher(['jf', 'setup', '--password-store', 'gnome-libsecret'], env);
|
||||
|
||||
assert.equal(result.status, 0);
|
||||
assert.equal(
|
||||
|
||||
@@ -475,8 +475,7 @@ export function startMpv(
|
||||
if (preloadedSubtitles?.secondaryPath) {
|
||||
mpvArgs.push(`--sub-file=${preloadedSubtitles.secondaryPath}`);
|
||||
}
|
||||
const aniSkipMetadata =
|
||||
targetKind === 'file' ? inferAniSkipMetadataForFile(target) : null;
|
||||
const aniSkipMetadata = targetKind === 'file' ? inferAniSkipMetadataForFile(target) : null;
|
||||
const scriptOpts = buildSubminerScriptOpts(appPath, socketPath, aniSkipMetadata);
|
||||
if (aniSkipMetadata) {
|
||||
log(
|
||||
|
||||
@@ -31,11 +31,7 @@ test('parseArgs maps jellyfin play action and log-level override', () => {
|
||||
});
|
||||
|
||||
test('parseArgs forwards jellyfin password-store option', () => {
|
||||
const parsed = parseArgs(
|
||||
['jf', 'setup', '--password-store', 'gnome-libsecret'],
|
||||
'subminer',
|
||||
{},
|
||||
);
|
||||
const parsed = parseArgs(['jf', 'setup', '--password-store', 'gnome-libsecret'], 'subminer', {});
|
||||
|
||||
assert.equal(parsed.jellyfin, true);
|
||||
assert.equal(parsed.passwordStore, 'gnome-libsecret');
|
||||
|
||||
Reference in New Issue
Block a user