forked from stenciljs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-version.ts
More file actions
35 lines (32 loc) · 1.21 KB
/
Copy pathcheck-version.ts
File metadata and controls
35 lines (32 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { isFunction } from '@utils';
import type { ValidatedConfig } from '../declarations';
/**
* Retrieve a reference to the active `CompilerSystem`'s `checkVersion` function
* @param config the Stencil configuration associated with the currently compiled project
* @param currentVersion the Stencil compiler's version string
* @returns a reference to `checkVersion`, or `null` if one does not exist on the current `CompilerSystem`
*/
export const startCheckVersion = async (
config: ValidatedConfig,
currentVersion: string,
): Promise<(() => void) | null> => {
if (config.devMode && !config.flags.ci && !currentVersion.includes('-dev.') && isFunction(config.sys.checkVersion)) {
return config.sys.checkVersion(config.logger, currentVersion);
}
return null;
};
/**
* Print the results of running the provided `versionChecker`.
*
* Does not print if no `versionChecker` is provided.
*
* @param versionChecker the function to invoke.
*/
export const printCheckVersionResults = async (versionChecker: Promise<(() => void) | null>): Promise<void> => {
if (versionChecker) {
const checkVersionResults = await versionChecker;
if (isFunction(checkVersionResults)) {
checkVersionResults();
}
}
};