This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support qmllint with PySide 6.4.1
Fix #255
- Loading branch information
1 parent
7c0f427
commit dc2f427
Showing
6 changed files
with
88 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { CommandArgs, ExecError, StdErrError } from '../../run' | ||
import { run } from '../../run' | ||
import type { ErrorResult, SuccessResult } from '../../types' | ||
|
||
export async function getVersion({ | ||
qmlLintCommand, | ||
}: GetVersionArgs): Promise<GetVersionResult> { | ||
const runResult = await run({ | ||
command: [...qmlLintCommand, '--version'], | ||
}) | ||
|
||
if (runResult.kind === 'Success') { | ||
const version = runResult.value.split(' ').at(-1)?.trim() | ||
if (typeof version !== 'string' || !checkVersionString(version)) | ||
return { | ||
kind: 'ParseError', | ||
message: `Could not parse version: ${version}`, | ||
} | ||
return { kind: 'Success', value: version } | ||
} | ||
|
||
return runResult | ||
} | ||
|
||
export type GetVersionArgs = { | ||
readonly qmlLintCommand: CommandArgs | ||
} | ||
|
||
export type GetVersionResult = | ||
| SuccessResult<Version> | ||
| ErrorResult<'Parse'> | ||
| ExecError | ||
| StdErrError | ||
|
||
export type Version = `${number}.${number}.${number}` | ||
|
||
function checkVersionString(version: string): version is Version { | ||
const versionRegex = /^\d+\.\d+\.\d+$/ | ||
return versionRegex.test(version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters