version
Helpers for gating formatter output on the target framework version.
FrameworkVersionβ
Defined in: version.ts:10
A framework version, narrowed down to the parts used for comparison.
Propertiesβ
majorβ
major: number;
Defined in: version.ts:11
minor?β
optional minor?: number;
Defined in: version.ts:12
isFrameworkVersion()β
function isFrameworkVersion(meta, framework, version): boolean;
Defined in: version.ts:109
Checks that the generator framework declared in meta is framework, and
that its version matches version.
Only the parts carried by version are compared, so { major: 2 } matches
any 2.x release. An unknown, unparsable or mismatched framework version
returns false.
Parametersβ
metaβ
Maybe<MetaInfo>
Optional metadata carrying the framework name and version
frameworkβ
string
The expected framework name, eg "docusaurus"
versionβ
The version to match
Returnsβ
boolean
true if the framework and its version match
Exampleβ
const meta = {
generatorFrameworkName: "docusaurus",
generatorFrameworkVersion: "2.4.3",
};
isFrameworkVersion(meta, "docusaurus", { major: 2 }); // true
isFrameworkVersion(meta, "docusaurus", { major: 3 }); // false
isFrameworkVersionAtLeast()β
function isFrameworkVersionAtLeast(meta, framework, minVersion): boolean;
Defined in: version.ts:140
Checks that the generator framework declared in meta is framework, and
that its version is minVersion or above.
An unknown, unparsable or mismatched framework version returns false, so
callers fall back to the output supported by every version.
Parametersβ
metaβ
Maybe<MetaInfo>
Optional metadata carrying the framework name and version
frameworkβ
string
The expected framework name, eg "docusaurus"
minVersionβ
The minimum version required by the caller
Returnsβ
boolean
true if the framework matches and its version is high enough
Exampleβ
const meta = {
generatorFrameworkName: "docusaurus",
generatorFrameworkVersion: "3.10.2",
};
isFrameworkVersionAtLeast(meta, "docusaurus", { major: 3, minor: 10 }); // true
isFrameworkVersionAtLeast(meta, "docusaurus", { major: 4 }); // false