當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript vso-task-lib.debug函數代碼示例

本文整理匯總了TypeScript中vso-task-lib.debug函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript debug函數的具體用法?TypeScript debug怎麽用?TypeScript debug使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了debug函數的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:

 files.forEach((file: string) => {
     var stagingPath = stagingFolder;
     if (useCommonRoot) {
         var relativePath = file.substring(commonRoot.length)
             .replace(/^\\/g, "")
             .replace(/^\//g, "");
         stagingPath = path.dirname(path.join(stagingFolder, relativePath));
     }
     
     if (!createdFolders[stagingPath]) {
         tl.debug("Creating folder " + stagingPath);
         tl.mkdirP(stagingPath);
         createdFolders[stagingPath] = true;
     }
     
     tl.debug("Copying " + file + " to " + stagingPath);
     tl.cp("-Rf", file, stagingPath);
 });
開發者ID:AnubhavAggarwal,項目名稱:vso-agent-tasks,代碼行數:18,代碼來源:publishBuildArtifacts.ts

示例3:

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

示例4:

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


注:本文中的vso-task-lib.debug函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。