Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: minimum for number of games with path characters #1016

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/modules/argumentsParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,12 @@ export default class ArgumentsParser {
}
const needOutput = ['copy', 'move', 'extract', 'zip', 'clean'].filter((command) => checkArgv._.includes(command));
if (!checkArgv.output && needOutput.length > 0) {
throw new Error(`Missing required option for command${needOutput.length !== 1 ? 's' : ''} ${needOutput.join(', ')}: --output`);
// TODO(cememr): print help message
throw new Error(`Missing required option for command${needOutput.length !== 1 ? 's' : ''} ${needOutput.join(', ')}: --output <path>`);
}
const needClean = ['clean-exclude', 'clean-dry-run'].filter((option) => checkArgv[option]);
if (!checkArgv._.includes('clean') && needClean.length > 0) {
// TODO(cememr): print help message
throw new Error(`Missing required command for option${needClean.length !== 1 ? 's' : ''} ${needClean.join(', ')}: clean`);
}
return true;
Expand Down
11 changes: 9 additions & 2 deletions src/types/dats/dat.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Memoize } from 'typescript-memoize';
import xml2js from 'xml2js';

import FsPoly from '../../polyfill/fsPoly.js';
Expand Down Expand Up @@ -62,6 +63,7 @@ export default abstract class DAT {
return this.getHeader().getName();
}

@Memoize()
getNameShort(): string {
return this.getName()
// Prefixes
Expand All @@ -86,9 +88,14 @@ export default abstract class DAT {
return this.getHeader().getDescription();
}

@Memoize()
getRomNamesContainDirectories(): boolean {
return this.getHeader().getRomNamesContainDirectories()
|| this.isBiosDat();
return this.getHeader().getRomNamesContainDirectories() ?? (
// Assume BIOS DATs know what they're doing with path characters
this.isBiosDat()
// At least 50% of games have at least one ROM with path characters
|| this.getGames().filter((game) => game.getRoms().some((rom) => rom.getName().match(/[\\/]/) !== null)).length > this.getGames().length / 2
);
}

/**
Expand Down
9 changes: 3 additions & 6 deletions src/types/dats/logiqx/header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class Header implements HeaderOptions {
@Transform(({ value }) => value || undefined)
readonly clrMamePro?: ClrMamePro;

readonly romNamesContainDirectories: boolean = true;
readonly romNamesContainDirectories?: boolean;

constructor(options?: HeaderOptions) {
this.name = options?.name ?? '';
Expand All @@ -89,10 +89,7 @@ export default class Header implements HeaderOptions {
this.url = options?.url;
this.comment = options?.comment;
this.clrMamePro = options?.clrMamePro;

this.romNamesContainDirectories = options?.romNamesContainDirectories !== undefined
? options?.romNamesContainDirectories
: false;
this.romNamesContainDirectories = options?.romNamesContainDirectories;
}

/**
Expand Down Expand Up @@ -132,7 +129,7 @@ export default class Header implements HeaderOptions {
return this.clrMamePro;
}

getRomNamesContainDirectories(): boolean {
getRomNamesContainDirectories(): boolean | undefined {
return this.romNamesContainDirectories;
}

Expand Down
Loading