本文整理汇总了TypeScript中semver.SemVer.compare方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SemVer.compare方法的具体用法?TypeScript SemVer.compare怎么用?TypeScript SemVer.compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类semver.SemVer
的用法示例。
在下文中一共展示了SemVer.compare方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: get
public get(entity: Entity, client: string, version: SemVer): Marshaller<Entity> {
let className: string = entity.constructor.name;
if (className.startsWith('Cart_')) {
if (version.compare(new SemVer('1.0.0')) === 0) {
return new CartMarshaller_01_00_00();
}
return new CartMarshaller_01_00_01();
}
if (className == 'Void') {
return new VoidMarshaller();
}
if (className.startsWith('HomeWidgets_')) {
if (client.startsWith('web')) {
if (version.compare(new SemVer('1.10.0')) >= 0) {
return new HomeWidgetsMarshaller_01_10_00();
}
}
return new HomeWidgetsMarshaller_01_00_00();
}
return null;
}
示例2: SemVer
'@angular/cli',
{
checkGlobal: false,
basedir: process.cwd(),
preserveSymlinks: true,
},
);
// This was run from a global, check local version.
const globalVersion = new SemVer(packageJson['version']);
let localVersion;
let shouldWarn = false;
try {
localVersion = _fromPackageJson();
shouldWarn = localVersion != null && globalVersion.compare(localVersion) > 0;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
shouldWarn = true;
}
if (shouldWarn && isWarningEnabled('versionMismatch')) {
const warning = terminal.yellow(tags.stripIndents`
Your global Angular CLI version (${globalVersion}) is greater than your local
version (${localVersion}). The local Angular CLI version is used.
To disable this warning use "ng config -g cli.warnings.versionMismatch false".
`);
// Don't show warning colorised on `ng completion`
if (process.argv[2] !== 'completion') {
示例3:
let ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();
num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;
comparatorResult = ver.compare(ver);
comparatorResult = ver.compareMain(ver);
comparatorResult = ver.comparePre(ver);
ver = ver.inc("major");
ver = ver.inc("premajor");
ver = ver.inc("minor");
ver = ver.inc("preminor");
ver = ver.inc("patch");
ver = ver.inc("prepatch");
ver = ver.inc("prerelease");
ver = ver.inc("prerelease", "alpha");
const comp = new semver.Comparator(str, bool);
str = comp.toString();
ver = comp.semver;
示例4:
var ver = new semver.SemVer(str, bool);
str = ver.raw;
bool = ver.loose;
str = ver.format();
str = ver.inspect();
str = ver.toString();
num = ver.major;
num = ver.minor;
num = ver.patch;
str = ver.version;
strArr = ver.build;
strArr = ver.prerelease;
num = ver.compare(ver);
num = ver.compareMain(ver);
num = ver.comparePre(ver);
ver = ver.inc(str);
var comp = new semver.Comparator(str, bool);
str = comp.toString();
ver = comp.semver;
str = comp.operator;
bool = comp.value;
comp.parse(str);
bool = comp.test(ver);
示例5: function
function (error: Error, projectLocalCli: string) {
let cli;
if (error) {
// If there is an error, resolve could not find the ng-cli
// library from a package.json. Instead, include it from a relative
// path to this script file (which is likely a globally installed
// npm package). Most common cause for hitting this is `ng new`
cli = require('./cli');
} else {
// This was run from a global, check local version.
const globalVersion = new SemVer(packageJson['version']);
let localVersion;
let shouldWarn = false;
try {
localVersion = _fromPackageJson();
shouldWarn = localVersion && globalVersion.compare(localVersion) > 0;
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
shouldWarn = true;
}
if (shouldWarn && isWarningEnabled('versionMismatch')) {
let warning = yellow(stripIndents`
Your global Angular CLI version (${globalVersion}) is greater than your local
version (${localVersion}). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
`);
// Don't show warning colorised on `ng completion`
if (process.argv[2] !== 'completion') {
// eslint-disable-next-line no-console
console.log(warning);
} else {
// eslint-disable-next-line no-console
console.error(warning);
process.exit(1);
}
}
// No error implies a projectLocalCli, which will load whatever
// version of ng-cli you have installed in a local package.json
cli = require(projectLocalCli);
}
if ('default' in cli) {
cli = cli['default'];
}
let standardInput;
try {
standardInput = process.stdin;
} catch (e) {
delete process.stdin;
process.stdin = new events.EventEmitter();
standardInput = process.stdin;
}
cli({
cliArgs: process.argv.slice(2),
inputStream: standardInput,
outputStream: process.stdout
}).then(function (exitCode: number) {
process.exit(exitCode);
}).catch(function(err: Error) {
console.log('Unknown error: ' + err.toString());
process.exit(127);
});
}