当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript semver.valid函数代码示例

本文整理汇总了TypeScript中semver.valid函数的典型用法代码示例。如果您正苦于以下问题:TypeScript valid函数的具体用法?TypeScript valid怎么用?TypeScript valid使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了valid函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: if

 return this.getVersionList().then(list => {
   let chromedriverVersion: string = null;
   let latest = '';
   let latestVersion = '';
   for (let item of list) {
     // Get a semantic version
     let version = item.split('/')[0];
     if (semver.valid(version) == null) {
       version += '.0';
       if (semver.valid(version)) {
         // First time: use the version found.
         if (chromedriverVersion == null) {
           chromedriverVersion = version;
           latest = item;
           latestVersion = item.split('/')[0];
         } else if (semver.gt(version, chromedriverVersion)) {
           // After the first time, make sure the semantic version is greater.
           chromedriverVersion = version;
           latest = item;
           latestVersion = item.split('/')[0];
         } else if (version === chromedriverVersion) {
           // If the semantic version is the same, check os arch.
           // For 64-bit systems, prefer the 64-bit version.
           if (this.osarch === 'x64') {
             if (item.includes(this.getOsTypeName() + '64')) {
               latest = item;
             }
           }
         }
       }
     }
   }
   return {url: Config.cdnUrls().chrome + latest, version: latestVersion};
 });
开发者ID:elgohr,项目名称:webdriver-manager,代码行数:34,代码来源:chrome_xml.ts

示例2:

    .sort((a, b) => {
      if (!semver.valid(a) && !semver.valid(b)) {
        return a.localeCompare(b);
      }

      if (!semver.valid(a)) {
        return -1;
      }

      if (!semver.valid(b)) {
        return 1;
      }

      return semver.gt(a, b, true) ? -1 : 1;
    })
开发者ID:bpasero,项目名称:fiddle,代码行数:15,代码来源:sorted-electron-map.ts

示例3: _isValid

  protected _isValid(version: Version, modifiedWith: Version): boolean {
    if (!semver.valid(version)) {
      this.log(
        "Generator version format doesn't follow SemVer: 1.2.3(-4|-alpha.5|-beta.6)"
      );
    } else if (semver.valid(modifiedWith) && semver.lt(version, modifiedWith)) {
      this.log(
        `Current generator version (${version}) is lower than that used last time (${modifiedWith})
Upgrade generator-wupjs before proceeding further`
      );
    } else {
      return true;
    }

    return false;
  }
开发者ID:jlenoble,项目名称:generator-wupjs,代码行数:16,代码来源:index.ts

示例4: main

async function main() {
	const validTag = !!semver.valid(commitMessage);
	if (!validTag) {
		console.log('Not a valid version tag, not publishing');
		return;
	}	
	if (process.env.TRAVIS_OS_NAME === 'osx') {
		const allReleases: GithubMeta<Release[]> = await gh.repos.getReleases({
			owner: 'SanderRonde',
			repo: 'media-app',
			per_page: 20,
			page: 0
		});

		const latestRelease = allReleases.data[0];
		if (latestRelease.tag_name !== `v${VERSION}`) {
			console.log('Latest release does not match this version, not publishing')
			return;
		}

		await gh.repos.editRelease({
			owner: 'SanderRonde',
			repo: 'media-app',
			id: latestRelease.id + '',
			tag_name: `v${VERSION}`,
			draft: false
		});

		console.log('Succesfully created release');
	} else {
		console.log('Not publishing since this is linux');	
	}
}
开发者ID:SanderRonde,项目名称:youtube-music-app,代码行数:33,代码来源:publish.ts

示例5: convertXmlToVersionList

export function convertXmlToVersionList(
    fileName: string, matchFile: string,
    versionParser: (key: string) => string | null,
    semanticVersionParser: (key: string) => string): VersionList|null {
  const xmlJs = readXml(fileName);
  if (!xmlJs) {
    return null;
  }
  const versionList: VersionList = {};
  for (const content of xmlJs['ListBucketResult']['Contents']) {
    const key = content['Key'][0] as string;
    if (key.includes(matchFile)) {
      const version = versionParser(key);
      if (version) {
        const semanticVersion = semanticVersionParser(key);
        if (!semver.valid(semanticVersion)) {
          continue;
        }
        const name = key.split('/')[1];
        const size = +content['Size'][0];
        if (!versionList[semanticVersion]) {
          versionList[semanticVersion] = {};
        }
        versionList[semanticVersion][name] = {name, size, url: key, version};
      }
    }
  }
  return versionList;
}
开发者ID:angular,项目名称:webdriver-manager,代码行数:29,代码来源:cloud_storage_xml.ts

示例6: updatePlatform

	private async updatePlatform(platform: string, version: string, platformTemplate: string, projectData: IProjectData, config: IPlatformOptions): Promise<void> {
		const platformData = this.$platformsData.getPlatformData(platform, projectData);

		const data = this.$projectDataService.getNSValue(projectData.projectDir, platformData.frameworkPackageName);
		const currentVersion = data && data.version ? data.version : "0.2.0";

		const installedModuleDir = temp.mkdirSync("runtime-to-update");
		let newVersion = version === constants.PackageVersion.NEXT ?
			await this.$packageInstallationManager.getNextVersion(platformData.frameworkPackageName) :
			version || await this.$packageInstallationManager.getLatestCompatibleVersion(platformData.frameworkPackageName);
		await this.$pacoteService.extractPackage(`${platformData.frameworkPackageName}@${newVersion}`, installedModuleDir);
		const cachedPackageData = this.$fs.readJson(path.join(installedModuleDir, "package.json"));
		newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;

		const canUpdate = platformData.platformProjectService.canUpdatePlatform(installedModuleDir, projectData);
		if (canUpdate) {
			if (!semver.valid(newVersion)) {
				this.$errors.fail("The version %s is not valid. The version should consists from 3 parts separated by dot.", newVersion);
			}

			if (!semver.gt(currentVersion, newVersion)) {
				await this.updatePlatformCore(platformData, { currentVersion, newVersion, canUpdate, platformTemplate }, projectData, config);
			} else if (semver.eq(currentVersion, newVersion)) {
				this.$errors.fail("Current and new version are the same.");
			} else {
				this.$errors.fail(`Your current version: ${currentVersion} is higher than the one you're trying to install ${newVersion}.`);
			}
		} else {
			this.$errors.failWithoutHelp("Native Platform cannot be updated.");
		}
	}
开发者ID:NativeScript,项目名称:nativescript-cli,代码行数:31,代码来源:platform-service.ts

示例7: fullyQualifyVersion

// We sometimes deal with 'x.y'-style version tags because the minor version doesn't
// really matter, but the semver module *requires* that we use x.y.z notation. So
// this module appends a '.0' to those versions to ensure that the semver module
// doesn't crash due to a version syntax problem.
function fullyQualifyVersion(version: string): string {
  if (!valid(version)) {
    return version + '.0';
  }

  return version;
}
开发者ID:forumone,项目名称:generator-web-starter,代码行数:11,代码来源:semverMax.ts

示例8: appendVersion

function appendVersion(packageToInstall: string, version: string) {
  const validSemver = semver.valid(version)
  if (validSemver) {
    packageToInstall += `@${validSemver}`
  }
  return packageToInstall
}
开发者ID:aranja,项目名称:tux,代码行数:7,代码来源:new.ts

示例9: return

		return (() => {
			let platformData = this.$platformsData.getPlatformData(platform);

			this.$projectDataService.initialize(this.$projectData.projectDir);
			let data = this.$projectDataService.getValue(platformData.frameworkPackageName).wait();
			let currentVersion = data && data.version ? data.version : "0.2.0";
			let newVersion = version || this.$npmInstallationManager.getLatestVersion(platformData.frameworkPackageName).wait();

			let cachedPackageData = this.$npmInstallationManager.addToCache(platformData.frameworkPackageName, newVersion).wait();
			newVersion = (cachedPackageData && cachedPackageData.version) || newVersion;

			let canUpdate = platformData.platformProjectService.canUpdatePlatform(currentVersion, newVersion).wait();
			if (canUpdate) {
				if (!semver.valid(newVersion)) {
					this.$errors.fail("The version %s is not valid. The version should consists from 3 parts separated by dot.", newVersion);
				}

				if (semver.gt(currentVersion, newVersion)) { // Downgrade
					let isUpdateConfirmed = this.$prompter.confirm(`You are going to downgrade to runtime v.${newVersion}. Are you sure?`, () => false).wait();
					if (isUpdateConfirmed) {
						this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
					}
				} else if (semver.eq(currentVersion, newVersion)) {
					this.$errors.fail("Current and new version are the same.");
				} else {
					this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
				}
			} else {
				this.updatePlatformCore(platformData, currentVersion, newVersion, canUpdate).wait();
			}

		}).future<void>()();
开发者ID:Emat12,项目名称:nativescript-cli,代码行数:32,代码来源:platform-service.ts

示例10:

          validate: (version: Version): true | string => {
            if (!semver.valid(version)) {
              return "Version format doesn't follow SemVer: 1.2.3(-4|-alpha.5|-beta.6)";
            }

            return true;
          }
开发者ID:jlenoble,项目名称:generator-wupjs,代码行数:7,代码来源:index.ts


注:本文中的semver.valid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。