kylin-code/build/lib/getVersion.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

17 lines
616 B
TypeScript
Raw Normal View History

2022-06-14 14:37:10 +08:00
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
2024-04-30 20:57:13 +08:00
import * as git from './git';
2022-06-14 14:37:10 +08:00
2024-04-30 20:57:13 +08:00
export function getVersion(root: string): string | undefined {
let version = process.env['BUILD_SOURCEVERSION'];
2022-06-14 14:37:10 +08:00
2024-04-30 20:57:13 +08:00
if (!version || !/^[0-9a-f]{40}$/i.test(version.trim())) {
version = git.getVersion(root);
2022-06-14 14:37:10 +08:00
}
2024-04-30 20:57:13 +08:00
return version;
2022-06-14 14:37:10 +08:00
}