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


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

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


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

示例1: RegExp

	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`);
			} else {
				data = data.replace(match[0], varValue);
				tl.debug(`... replaced token ${varName}`);
			}
		}
		console.info("Writing new values to file");
		fs.writeFileSync(file, data);
		
		tl.debug("Leaving Replace Tokens step");
	});
开发者ID:BigDataTechnology,项目名称:cols-agent-tasks,代码行数:26,代码来源:replaceTokens.ts

示例2: RegExp

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 separator = os.platform() === "win32" ? "\\" : "/";

// create a glob removing any spurious quotes
var globPattern = `${sourcePath}${separator}${filePattern}`.replace(/\"/g,"");
var files = tl.glob(globPattern);
if (files.length === 0) {
    tl.error(`Could not find files with glob [${globPattern}]`);
    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();
    var reg = new RegExp(tokenRegex, "g");
            
    // loop through each match
    var match: RegExpExecArray;
    while((match = reg.exec(contents)) !== null) {
        var vName = match[1];
        if (typeof secretTokens[vName.toLowerCase()] !== "undefined") {
开发者ID:nphmuller,项目名称:cols-agent-tasks,代码行数:31,代码来源:replaceTokens.ts

示例3: RegExp

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();
    var reg = new RegExp(tokenRegex, "g");
            
    // loop through each match
    var match: RegExpExecArray;
    while((match = reg.exec(contents)) !== null) {
        // find the variable value in the environment
        var vName = match[1];
开发者ID:richardacre,项目名称:cols-agent-tasks,代码行数:31,代码来源:replaceTokens.ts

示例4: if

                
                tl.debug("Copying " + file + " to " + stagingPath);
                tl.cp("-Rf", file, stagingPath);
            });

            var data = {
                artifacttype: artifactType,
                artifactname: artifactName
            };
    
            // upload or copy
            if (artifactType === "container") {
                data["containerfolder"] = artifactName;
                data["localpath"] = stagingFolder;
                tl.command("artifact.upload", data, "Uploading artifact");
            }
            else if (artifactType === "filepath") {
                tl.mkdirP(targetPath);
                tl.cp("-Rf", stagingFolder, targetPath);

                data["artifactlocation"] = targetPath;
                tl.command("artifact.associate", data, "Associating artifact");
            }
        }
        catch (err) {
            tl.error(err);
            tl.exit(1);
        }
    }
}
开发者ID:AnubhavAggarwal,项目名称:vso-agent-tasks,代码行数:29,代码来源:publishBuildArtifacts.ts


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