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


TypeScript semver.minor函数代码示例

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


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

示例1: gnomeTerminalVersion

    gnomeTerminalVersion((version: string) => {
      logHelper.logStepStarted('gnome-terminal');
      if (version === undefined || !semver.valid(version)) {
        logHelper.logSubStepFail('gnome-terminal doesn\'t seem to be installed');
        return;
      }

      if (semver.major(version) === 3 && semver.minor(version) >= 8 || semver.major(version) > 3) {
        execAndReportSync('applying profile theme (Gnome 3.8+)', path.join(__dirname, '../../data/gnome-terminal/profile-theme-3.8.sh'));
      } else {
        execAndReportSync('applying profile theme', path.join(__dirname, 'profile-theme.sh'));
      }
    });
开发者ID:Tyriar,项目名称:dotfiles,代码行数:13,代码来源:gnome-terminal.ts

示例2: ngOnInit

  ngOnInit() {
    let version = this.installation.version;
    let currentVersion = this.installation.currentVersion;
    let versionMatch = /^(([0-9]+\.){2}[0-9]+)/.exec(version);

    if (versionMatch) {
      version = versionMatch[1];
    } else {
      this.status = "outdated";
      return null;
    }

    let major = semver.major(version);
    let minor = semver.minor(version);
    let patch = semver.patch(version);

    let currentMajor = semver.major(currentVersion);
    let currentMinor = semver.minor(currentVersion);
    let currentPatch = semver.patch(currentVersion);

    if (
      semver.satisfies(
        `${major}.${minor}.${patch}`,
        `>=${currentMajor}.${currentMinor}.${currentPatch}`
      )
    ) {
      this.status = "up-to-date";
    } else if (
      semver.satisfies(
        `${major}.${minor}.${patch}`,
        `>=${currentMajor}.${currentMinor}.x`
      )
    ) {
      this.status = "same-minor";
    } else {
      this.status = "outdated";
    }
  }
开发者ID:isaacmg410,项目名称:decidim-monitor,代码行数:38,代码来源:app-installation.component.ts

示例3: getLatestCompatibleVersion

	public async getLatestCompatibleVersion(packageName: string, referenceVersion?: string): Promise<string> {
		referenceVersion = referenceVersion || this.$staticConfig.version;
		const isPreReleaseVersion = semver.prerelease(referenceVersion) !== null;
		// if the user has some v.v.v-prerelease-xx.xx pre-release version, include pre-release versions in the search query.
		const compatibleVersionRange = isPreReleaseVersion
			? `~${referenceVersion}`
			: `~${semver.major(referenceVersion)}.${semver.minor(referenceVersion)}.0`;
		const latestVersion = await this.getLatestVersion(packageName);
		if (semver.satisfies(latestVersion, compatibleVersionRange)) {
			return latestVersion;
		}

		const data = await this.$npm.view(packageName, { "versions": true });

		const maxSatisfying = semver.maxSatisfying(data, compatibleVersionRange);
		return maxSatisfying || latestVersion;
	}
开发者ID:NathanaelA,项目名称:nativescript-cli,代码行数:17,代码来源:npm-installation-manager.ts

示例4: useCpythonVersion

async function useCpythonVersion(parameters: Readonly<TaskParameters>, platform: Platform): Promise<void> {
    const desugaredVersionSpec = desugarDevVersion(parameters.versionSpec);
    const semanticVersionSpec = pythonVersionToSemantic(desugaredVersionSpec);
    task.debug(`Semantic version spec of ${parameters.versionSpec} is ${semanticVersionSpec}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticVersionSpec, parameters.architecture);
    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec, parameters.architecture),
            task.loc('ListAvailableVersions', task.getVariable('Agent.ToolsDirectory')),
            x86Versions,
            x64Versions,
            task.loc('ToolNotFoundMicrosoftHosted', 'Python', 'https://aka.ms/hosted-agent-software'),
            task.loc('ToolNotFoundSelfHosted', 'Python', 'https://go.microsoft.com/fwlink/?linkid=871498')
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);
    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);
        toolUtil.prependPathSafe(binDir(installDir, platform))

        if (platform === Platform.Windows) {
            // Add --user directory
            // `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
            const version = path.basename(path.dirname(installDir));
            const major = semver.major(version);
            const minor = semver.minor(version);

            const userScriptsDir = path.join(process.env['APPDATA'], 'Python', `Python${major}${minor}`, 'Scripts');
            toolUtil.prependPathSafe(userScriptsDir);
        }
        // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
    }
}
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:45,代码来源:usepythonversion.ts

示例5: getSemanticVersion

export function getSemanticVersion() {
    const options = minimist(process.argv.slice(2), {});
    let version = options.version;
    if (!version) {
        version = "0.0.0";
        console.log("No version argument provided, fallback to default version: " + version);
    } else {
        console.log("Found version: " + version);
    }

    if (!semver.valid(version)) {
        throw new Error("Package: invalid semver version: " + version);
    }

    let patch = semver.patch(version);

    if (!options.noversiontransform) {
        patch *= 1000;
        const prerelease = semver.prerelease(version);
        if (prerelease) {
            patch += parseInt(prerelease[1], 10);
        } else {
            patch += 999;
        }
    }

    const result = {
        major: semver.major(version),
        minor: semver.minor(version),
        patch,
        getVersionString() {
            return this.major.toString() + "." + this.minor.toString() + "." + this.patch.toString();
        },
    };

    console.log("Extension Version: " + result.getVersionString());

    return result;
}
开发者ID:geeklearningio,项目名称:gl-vsts-tasks-build-scripts,代码行数:39,代码来源:extension-version.ts

示例6: require

#!/usr/bin/env ts-node
/**
 * Author: Huan LI <zixia@zixia.net>
 * https://github.com/zixia
 * License: Apache-2.0
 */
import { minor } from 'semver'

const version: string = require('../package.json').version

if (minor(version) % 2 === 0) { // production release
  console.log(`${version} is production release`)
  process.exit(1) // exit 1 for not development
}

// development release
console.log(`${version} is development release`)
process.exit(0)
开发者ID:miggame,项目名称:wechaty,代码行数:18,代码来源:development-release.ts

示例7: usePythonVersion

export async function usePythonVersion(parameters: Readonly<TaskParameters>, platform: Platform): Promise<void> {
    // Python's prelease versions look like `3.7.0b2`.
    // This is the one part of Python versioning that does not look like semantic versioning, which specifies `3.7.0-b2`.
    // If the version spec contains prerelease versions, we need to convert them to the semantic version equivalent
    const semanticVersionSpec = pythonVersionToSemantic(parameters.versionSpec);
    task.debug(`Semantic version spec of ${parameters.versionSpec} is ${semanticVersionSpec}`);

    const installDir: string | null = tool.findLocalTool('Python', semanticVersionSpec, parameters.architecture);
    if (!installDir) {
        // Fail and list available versions
        const x86Versions = tool.findLocalToolVersions('Python', 'x86')
            .map(s => `${s} (x86)`)
            .join(os.EOL);

        const x64Versions = tool.findLocalToolVersions('Python', 'x64')
            .map(s => `${s} (x64)`)
            .join(os.EOL);

        throw new Error([
            task.loc('VersionNotFound', parameters.versionSpec),
            task.loc('ListAvailableVersions'),
            x86Versions,
            x64Versions
        ].join(os.EOL));
    }

    task.setVariable('pythonLocation', installDir);
    if (parameters.addToPath) {
        toolUtil.prependPathSafe(installDir);

        // Make sure Python's "bin" directories are in PATH.
        // Python has "scripts" or "bin" directories where command-line tools that come with packages are installed.
        // This is where pip is, along with anything that pip installs.
        // There is a seperate directory for `pip install --user`.
        //
        // For reference, these directories are as follows:
        //   macOS / Linux:
        //      <sys.prefix>/bin (by default /usr/local/bin, but not on hosted agents -- see the `else`)
        //      (--user) ~/.local/bin
        //   Windows:
        //      <Python installation dir>\Scripts
        //      (--user) %APPDATA%\Python\PythonXY\Scripts
        // See https://docs.python.org/3/library/sysconfig.html
        if (platform === Platform.Windows) {
            // On Windows, these directories do not get added to PATH, so we will add them ourselves.
            const scriptsDir = path.join(installDir, 'Scripts');
            toolUtil.prependPathSafe(scriptsDir);

            // Add --user directory
            // `installDir` from tool cache should look like $AGENT_TOOLSDIRECTORY/Python/<semantic version>/x64/
            // So if `findLocalTool` succeeded above, we must have a conformant `installDir`
            const version = path.basename(path.dirname(installDir));
            const major = semver.major(version);
            const minor = semver.minor(version);

            const userScriptsDir = path.join(process.env['APPDATA'], 'Python', `Python${major}${minor}`, 'Scripts');
            toolUtil.prependPathSafe(userScriptsDir);
        } else {
            // On Linux and macOS, tools cache should be set up so that each Python version has its own "bin" directory.
            // We do this so that the tool cache can just be dropped on an agent with minimal installation (no copying to /usr/local).
            // This allows us side-by-side the same minor version of Python with different patch versions or architectures (since Python uses /usr/local/lib/python3.6, etc.).
            toolUtil.prependPathSafe(path.join(installDir, 'bin'));

            // On Linux and macOS, pip will create the --user directory and add it to PATH as needed.
        }
    }
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:67,代码来源:usepythonversion.ts

示例8:

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);

// Comparison
bool = semver.gt(v1, v2, loose);
bool = semver.gte(v1, v2, loose);
bool = semver.lt(v1, v2, loose);
bool = semver.lte(v1, v2, loose);
bool = semver.eq(v1, v2, loose);
bool = semver.neq(v1, v2, loose);
bool = semver.cmp(v1, op, v2, loose);
comparatorResult = semver.compare(v1, v2, loose);
comparatorResult = semver.rcompare(v1, v2, loose);
comparatorResult = semver.compareIdentifiers(str, str);
comparatorResult = semver.rcompareIdentifiers(str, str);
开发者ID:PriceSpider-NeuIntel,项目名称:DefinitelyTyped,代码行数:31,代码来源:semver-tests.ts

示例9: wizard

export default async function wizard(pwd: string, name: string) {
  let its = validateName(name);
  if (!its.validForNewPackages) {
    let errors = (its.errors || []).concat(its.warnings || []);
    throw new Error("Sorry, " + errors.join(" and ") + ".");
  }

  // check for a scoped name
  let scoped = name.match(/@([^\/]+)\/(.*)/);
  let [, scope, local] = scoped ? (scoped as [string, string, string]) : [, null, name];

  console.log("This utility will walk you through creating the " + style.project(name) + " Neon project.");
  console.log("It only covers the most common items, and tries to guess sensible defaults.");
  console.log();
  console.log("Press ^C at any time to quit.");

  let root = path.resolve(pwd, local);
  let guess = await guessAuthor();

  let answers = await prompt([
    {
      type: 'input',
      name: 'version',
      message: "version",
      default: "0.1.0",
      validate: function (input) {
        if (semver.valid(input)) {
          return true;
        }
        return "Invalid version: " + input;
      }
    },
    { type: 'input', name: 'description', message: "description"                               },
    { type: 'input', name: 'node',        message: "node entry point", default: "lib/index.js" },
    { type: 'input', name: 'git',         message: "git repository"                            },
    { type: 'input', name: 'author',      message: "author",           default: guess.name     },
    { type: 'input', name: 'email',       message: "email",            default: guess.email    },
    {
      type: 'input',
      name: 'license',
      message: "license",
      default: "MIT",
      validate: function (input) {
        let its = validateLicense(input);
        if (its.validForNewPackages) {
          return true;
        }
        let errors = its.warnings || [];
        return "Sorry, " + errors.join(" and ") + ".";
      }
    }
  ]);

  answers.name = {
    npm: {
      full: name,
      scope: scope,
      local: local
    },
    cargo: {
      external: local,
      internal: local.replace(/-/g, "_")
    }
  };
  answers.description = escapeQuotes(answers.description);
  answers.git = encodeURI(answers.git);
  answers.author = escapeQuotes(answers.author);

  let ctx = {
    project: answers,
    "neon-cli": {
      major: semver.major(NEON_CLI_VERSION),
      minor: semver.minor(NEON_CLI_VERSION),
      patch: semver.patch(NEON_CLI_VERSION)
    }
  };

  let lib = path.resolve(root, path.dirname(answers.node));
  let native_ = path.resolve(root, 'native');
  let src = path.resolve(native_, 'src');

  await mkdirs(lib);
  await mkdirs(src);

  await writeFile(path.resolve(root,    '.gitignore'),   (await GITIGNORE_TEMPLATE)(ctx), { flag: 'wx' });
  await writeFile(path.resolve(root,    'package.json'), (await NPM_TEMPLATE)(ctx),       { flag: 'wx' });
  await writeFile(path.resolve(native_, 'Cargo.toml'),   (await CARGO_TEMPLATE)(ctx),     { flag: 'wx' });
  await writeFile(path.resolve(root,    'README.md'),    (await README_TEMPLATE)(ctx),    { flag: 'wx' });
  await writeFile(path.resolve(root,    answers.node),   (await INDEXJS_TEMPLATE)(ctx),   { flag: 'wx' });
  await writeFile(path.resolve(src,     'lib.rs'),       (await LIBRS_TEMPLATE)(ctx),     { flag: 'wx' });
  await writeFile(path.resolve(native_, 'build.rs'),     (await BUILDRS_TEMPLATE)(ctx),   { flag: 'wx' });

  let relativeRoot = path.relative(pwd, root);
  let relativeNode = path.relative(pwd, path.resolve(root, answers.node));
  let relativeRust = path.relative(pwd, path.resolve(src, 'lib.rs'));

  console.log();
  console.log("Woo-hoo! Your Neon project has been created in: " + style.path(relativeRoot));
  console.log();
  console.log("The main Node entry point is at: " + style.path(relativeNode));
//.........这里部分代码省略.........
开发者ID:kodeballer,项目名称:neon,代码行数:101,代码来源:neon_new.ts

示例10:

#!/usr/bin/env ts-node
/**
 * Author: Huan LI <zixia@zixia.net>
 * https://github.com/zixia
 * License: Apache-2.0
 */
import readPkgUp from 'read-pkg-up'
import { minor } from 'semver'

const pkg = readPkgUp.sync({ cwd: __dirname }).pkg
export const VERSION = pkg.version

if (minor(VERSION) % 2 === 0) { // production release
  console.log(`${VERSION} is production release`)
  process.exit(1) // exit 1 for not development
}

// development release
console.log(`${VERSION} is development release`)
process.exit(0)
开发者ID:KiddoLin,项目名称:wechaty,代码行数:20,代码来源:development-release.ts


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