Skip to content

Commit

Permalink
feat: deduplicate log (#275)
Browse files Browse the repository at this point in the history
When adding a package the app will warn if the version inside ProjectVersion.txt is malformed. If multiple packages are added it will make this warning for each package.

This seems a bit redundant. Probably we should only log the warning once at the beginning of the add operation.
  • Loading branch information
ComradeVanti committed Apr 22, 2024
1 parent 7d795d9 commit 31e7f42
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/cli/cmd-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export function makeAddCmd(
if (envResult.isErr()) return envResult;
const env = envResult.value;

if (typeof env.editorVersion === "string")
log.warn(
"editor.version",
`${env.editorVersion} is unknown, the editor version check is disabled`
);

const tryAddToManifest = async function (
manifest: UnityProjectManifest,
pkg: PackageReference
Expand Down Expand Up @@ -173,31 +179,27 @@ export function makeAddCmd(
const targetEditorVersion = targetEditorVersionResult.value;

// verify editor version
if (targetEditorVersion !== null) {
if (typeof env.editorVersion === "string") {
log.warn(
"editor.version",
`${env.editorVersion} is unknown, the editor version check is disabled`
);
} else if (
compareEditorVersion(env.editorVersion, targetEditorVersion) < 0
) {
log.warn(
"editor.version",
`requires ${targetEditorVersion} but found ${stringifyEditorVersion(
env.editorVersion
)}`
if (
targetEditorVersion !== null &&
typeof env.editorVersion !== "string" &&
compareEditorVersion(env.editorVersion, targetEditorVersion) < 0
) {
log.warn(
"editor.version",
`requires ${targetEditorVersion} but found ${stringifyEditorVersion(
env.editorVersion
)}`
);
if (!options.force) {
log.notice(
"suggest",
`upgrade the editor to ${targetEditorVersion}, or run with option -f to ignore the warning`
);
if (!options.force) {
log.notice(
"suggest",
`upgrade the editor to ${targetEditorVersion}, or run with option -f to ignore the warning`
);
return Err(new EditorIncompatibleError());
}
return Err(new EditorIncompatibleError());
}
}
}

// pkgsInScope
if (!isUpstreamPackage) {
log.verbose(
Expand Down

0 comments on commit 31e7f42

Please sign in to comment.