本文整理汇总了TypeScript中semver.clean函数的典型用法代码示例。如果您正苦于以下问题:TypeScript clean函数的具体用法?TypeScript clean怎么用?TypeScript clean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clean函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: updateChangelogs
function updateChangelogs(
changelogs: ChangelogOfVersion[],
version: string,
prs: GithubIssue[],
): ChangelogOfVersion[] {
const prevChangelog = getChangelogOfVersion(changelogs, version);
const newChangelog: ChangelogOfVersion = {
version: semver.clean(version),
items: prs.map(parsePrToChangelogItem),
};
if (prevChangelog) {
const index = changelogs.indexOf(prevChangelog);
changelogs[index] = newChangelog;
} else {
changelogs.push(newChangelog);
}
// Sort desc by version.
return changelogs.sort((a, b) => {
if (semver.gt(a.version, b.version)) {
return -1;
} else if (semver.lt(a.version, b.version)) {
return 1;
} else {
return 0;
}
});
}
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:30,代码来源:changelog.ts
示例2: getVersion
async function getVersion(program: string, command: string, matcher: RegExp): Promise<string> {
try {
const result = await tryExecuteCommand(undefined, program, command);
if (result.code === 0) {
const output = result.cmdOutput || result.cmdOutputIncludingStderr;
const truffleVersion = output.match(matcher);
const version = semver.clean(truffleVersion ? truffleVersion[1] : '');
return version || '';
}
} catch (error) {
// ignore error
}
return '';
}
开发者ID:chrisseg,项目名称:vscode-azure-blockchain-ethereum,代码行数:16,代码来源:required.ts
示例3:
let exp: RegExp;
let strArr: string[] | null;
let numArr: string[];
let comparatorResult: -1 | 0 | 1;
let versionsArr: Array<string | semver.SemVer>;
let v1: string = '';
let v2: string = '';
let version: string = '';
let versions: string[] = [];
let loose: boolean = true;
let sem: semver.SemVer | null;
sem = semver.parse(str);
strn = semver.valid(str);
strn = semver.clean(str);
strn = semver.valid(str, loose);
strn = semver.clean(str, loose);
strn = semver.inc(str, "major", loose);
strn = semver.inc(str, "premajor", loose);
strn = semver.inc(str, "minor", loose);
strn = semver.inc(str, "preminor", loose);
strn = semver.inc(str, "patch", loose);
strn = semver.inc(str, "prepatch", loose);
strn = semver.inc(str, "prerelease", loose);
strn = semver.inc(str, "prerelease", loose, "alpha");
num = semver.major(str, loose);
num = semver.minor(str, loose);
num = semver.patch(str, loose);
strArr = semver.prerelease(str, loose);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts
示例4:
const releaseTypes = ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];
const releaseType = argv._[0] || "patch";
let newVersion = releaseType;
const oldVersion = pack.version as string;
if (releaseTypes.indexOf(releaseType) > -1) {
if (releaseType.startsWith("pre") && argv._.length >= 2) {
// increment to pre-release with an additional prerelease string
newVersion = semver.inc(oldVersion, releaseType, argv._[1]);
} else {
newVersion = semver.inc(oldVersion, releaseType);
}
console.log(`bumping version ${colors.blue(oldVersion)} to ${colors.gray(releaseType)} version ${colors.green(newVersion)}\n`);
} else {
// increment to specific version
newVersion = semver.clean(newVersion);
if (newVersion == null) {
fail(`invalid version string "${newVersion}"`);
} else {
// valid version string => check if its actually newer
if (!semver.gt(newVersion, pack.version)) {
fail(`new version ${newVersion} is NOT > than package.json version ${pack.version}`);
}
// if (!semver.gt(newVersion, ioPack.common.version)) {
// fail(`new version ${newVersion} is NOT > than io-package.json version ${ioPack.common.version}`);
// }
}
console.log(`bumping version ${oldVersion} to specific version ${newVersion}`);
}
if (argv.dry) {
开发者ID:AlCalzone,项目名称:shared-utils,代码行数:31,代码来源:release.ts
示例5: getChangelogOfVersion
function getChangelogOfVersion(changelogs: ChangelogOfVersion[], version: string): ChangelogOfVersion | undefined {
const cleanVersion = semver.clean(version);
return changelogs.find(changelog => changelog.version === cleanVersion);
}
开发者ID:suiruiw,项目名称:geeks-diary,代码行数:4,代码来源:changelog.ts
示例6: toTRY
/**
* @author TĂźmay Ăeber <[email protected]>
* @link https://github.com/brendtumi/bkmexpress
* @license http://opensource.org/licenses/MIT
* @date 28.04.2017
*/
import * as semver from "semver";
import {MoneyUtilException} from "./exceptions";
const nodeVersion = semver.clean(process.version);
export class MoneyUtils {
public static toTRY(amount: number): string {
let formatted: string;
if (semver.lt(nodeVersion, "4.0.0")) {
formatted = (Math.round(amount * 100) / 100).toString();
const split: string[] = formatted.split(".");
if (split.length === 1 || split[1].length < 1) {
split[1] = "00";
}
else if (split[1].length < 2) {
split[1] = split[1] + "0";
}
formatted = split.join(",");
}
else {
formatted = amount.toLocaleString("tr-TR", {style: "currency", currency: "TRY", currencyDisplay: "code"});
formatted = formatted.replace(/TRY|,|\s+/gi, "");
formatted = formatted.replace(/\./i, ",");
}
return MoneyUtils.validate(formatted);
}
开发者ID:brendtumi,项目名称:bkmexpress,代码行数:31,代码来源:moneyUtils.ts
注:本文中的semver.clean函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论