文件操作 - version.ts
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/core/utils/version.ts
编辑文件内容
import _ from 'lodash'; const versionPattern = /^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z\.]+))?/; export class SemVersion { major: number; minor: number; patch: number; meta: string; constructor(version: string) { const match = versionPattern.exec(version); if (match) { this.major = Number(match[1]); this.minor = Number(match[2] || 0); this.patch = Number(match[3] || 0); this.meta = match[4]; } } isGtOrEq(version: string): boolean { const compared = new SemVersion(version); for (let i = 0; i < this.comparable.length; ++i) { if (this.comparable[i] > compared.comparable[i]) { return true; } if (this.comparable[i] < compared.comparable[i]) { return false; } } return true; } isValid(): boolean { return _.isNumber(this.major); } get comparable() { return [this.major, this.minor, this.patch]; } } export function isVersionGtOrEq(a: string, b: string): boolean { const aSemver = new SemVersion(a); return aSemver.isGtOrEq(b); }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件