• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript vso-task-lib.getInput函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1:

import * as tl from 'vso-task-lib';
import * as sh from 'shelljs';
import * as fs from 'fs';
import * as os from 'os';

tl.debug("Starting Replace Tokens task");

// get the task vars
var sourcePath = tl.getPathInput("sourcePath", true, true);
// clear leading and trailing quotes for paths with spaces
sourcePath = sourcePath.replace(/"/g, "");

var filePattern = tl.getInput("filePattern", true);
var tokenRegex = tl.getInput("tokenRegex", true);
var secretTokenInput = tl.getInput("secretTokens", false);

// store the tokens and values if there is any secret token input 
var secretTokens: {[id: string]: string} = {};
if (typeof secretTokenInput !== "undefined") {
    var inputArray : string[] = secretTokenInput.split(";");
    for (var token of inputArray) {
        if (token.indexOf(":") > -1) {  
            var valArray : string[] = token.split(":");
            if (valArray.length == 2) {
                var key = valArray[0].trim().toLowerCase();
                secretTokens[key] = valArray[1].trim();
                console.log(`Secret token input found [${key}]`); 
            }
        }
    }
    tl.debug(`secretTokens: found [${Object.keys(secretTokens).length}] tokens`);    
开发者ID:nphmuller,项目名称:cols-agent-tasks,代码行数:31,代码来源:replaceTokens.ts


示例2:

import * as tl from 'vso-task-lib';
import * as sh from 'shelljs';
import * as fs from 'fs';

tl.debug("Starting Replace Tokens step");

// get the task vars
var sourcePath = tl.getPathInput("sourcePath", true, true);
var filePattern = tl.getInput("filePattern", true);
var tokenRegex = tl.getInput("tokenRegex", true);

tl.debug(`sourcePath :${sourcePath}`);
tl.debug(`filePattern : ${filePattern}`);
tl.debug(`tokenRegex : ${tokenRegex}`);

if (filePattern === undefined || filePattern.length === 0){
	filePattern = "*.*";
}
tl.debug(`Using ${filePattern} as filePattern`);

var files = tl.glob(`${sourcePath}\\${filePattern}`);
if (files.length === 0) {
    tl.error(`Could not find files with pattern [${filePattern}] in path [${sourcePath}]`);
    tl.exit(1);
}

for (var i = 0; i < files.length; i++) {
	var file = files[i];
    console.info(`Starting regex replacement in ${file}`);
	
	var contents = fs.readFileSync(file, 'utf8').toString();
开发者ID:richardacre,项目名称:cols-agent-tasks,代码行数:31,代码来源:replaceTokens.ts


示例3: RegExp

import * as tl from 'vso-task-lib';
import * as sh from 'shelljs';
import * as fs from 'fs';

tl.debug("Starting Replace Tokens step");

// get the task vars
var filePath = tl.getPathInput("filePath", true, true);
var tokenRegex = tl.getInput("tokenRegex", true);

var files = tl.find(filePath);
if (files.length === 1) {
	var file = files[0];
	
	// read the file
	fs.readFile(file, 'utf8', (err, data) => {
		if (err) {
			tl.error(`Could not read file ${filePath}. Error is ${err.message}`);
			tl.exit(1);
		} 
		
		var reg = new RegExp(tokenRegex, "g");
		console.info(`Starting regex replacement in ${file}`);
		// loop through each match
		var match: RegExpExecArray;
		while((match = reg.exec(data)) !== null) {
			// find the variable value in the environment
			var varName = match[1];
			var varValue = tl.getVariable(varName);
			if (typeof varValue === 'undefined') {
				tl.warning(`... token ${varName} does not have an environment value`);
开发者ID:BigDataTechnology,项目名称:cols-agent-tasks,代码行数:31,代码来源:replaceTokens.ts


示例4: while

    var current = path.normalize(fullPath);
    var parentPath = path.dirname(current);
    var count = 0;
    while (parentPath !== current) {
        ++count;
        current = parentPath;
        parentPath = path.dirname(current);
    }

    return count;
}

// contents is a multiline input containing glob patterns
var contents: string[] = tl.getDelimitedInput('Contents', '\n');
var artifactName: string = tl.getInput('ArtifactName');
var artifactType: string = tl.getInput('ArtifactType');
// targetPath is used for file shares
var targetPath: string = tl.getInput('TargetPath');
var findRoot: string = tl.getPathInput('CopyRoot');

if (!artifactName) {
    // nothing to do
    tl.warning('Artifact name is not specified.');
}
else if (!artifactType) {
    // nothing to do
    tl.warning('Artifact type is not specified.');
}
else {
    artifactType = artifactType.toLowerCase();
开发者ID:AnubhavAggarwal,项目名称:vso-agent-tasks,代码行数:30,代码来源:publishBuildArtifacts.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript vso-task-lib.getPathInput函数代码示例发布时间:2022-05-25
下一篇:
TypeScript vso-task-lib.exit函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap