本文整理汇总了TypeScript中vsts-task-lib/task.loc函数的典型用法代码示例。如果您正苦于以下问题:TypeScript loc函数的具体用法?TypeScript loc怎么用?TypeScript loc使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loc函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: findDockerFile
function findDockerFile(dockerfilepath : string) : string {
if (dockerfilepath.indexOf('*') >= 0 || dockerfilepath.indexOf('?') >= 0) {
tl.debug(tl.loc('ContainerPatternFound'));
var buildFolder = tl.getVariable('System.DefaultWorkingDirectory');
var allFiles = tl.find(buildFolder);
var matchingResultsFiles = tl.match(allFiles, dockerfilepath, buildFolder, { matchBase: true });
if (!matchingResultsFiles || matchingResultsFiles.length == 0) {
throw new Error(tl.loc('ContainerDockerFileNotFound', dockerfilepath));
}
return matchingResultsFiles[0];
}
else
{
tl.debug(tl.loc('ContainerPatternNotFound'));
return dockerfilepath;
}
}
示例2: if
httpObj.get('GET', restUrl, requestHeader, (error, response, body) => {
if(error) {
deferred.reject(error);
}
else if(response.statusCode === 200) {
deferred.resolve(JSON.parse(body));
}
else {
deferred.reject(tl.loc("CouldNotFetchNetworkInterface", name, response.statusCode, response.statusMessage, body));
}
});
示例3: getVersionCompleteFileName
private getVersionCompleteFileName(name: string): string {
if (name && name.endsWith(".complete")) {
var parts = name.split('.');
var fileNameWithoutExtensionLength = name.length - (parts[parts.length - 1].length + 1);
if (fileNameWithoutExtensionLength > 0) {
return name.substr(0, fileNameWithoutExtensionLength);
}
}
throw tl.loc("FileNameNotCorrectCompleteFileName", name);
}
示例4: constructor
constructor(packageType: string, installationPath: string) {
try {
tl.exist(installationPath) || tl.mkdirP(installationPath);
}
catch (ex) {
throw tl.loc("UnableToAccessPath", installationPath, JSON.stringify(ex));
}
this.packageType = packageType;
this.installationPath = installationPath;
}
示例5: VersionInfo
channelReleases.forEach((release) => {
if (release && release[packageType] && release[packageType].version) {
try {
let versionInfo: VersionInfo = new VersionInfo(release[packageType], packageType);
versionInfoList.push(versionInfo);
}
catch (err) {
tl.debug(tl.loc("VersionInformationNotComplete", release[packageType].version, err));
}
}
});
示例6: getDistributionBatchSize
function getDistributionBatchSize(dtaTestConfiguration: models.DtaTestConfigurations) {
const distributeOption = tl.getInput('distributionBatchType');
if (distributeOption && distributeOption === 'basedOnTestCases') {
dtaTestConfiguration.batchingType = models.BatchingType.TestCaseBased;
// flow if the batch type = based on agents/custom batching
const distributeByAgentsOption = tl.getInput('batchingBasedOnAgentsOption');
if (distributeByAgentsOption && distributeByAgentsOption === 'customBatchSize') {
const batchSize = parseInt(tl.getInput('customBatchSizeValue'));
if (!isNaN(batchSize) && batchSize > 0) {
dtaTestConfiguration.numberOfTestCasesPerSlice = batchSize;
console.log(tl.loc('numberOfTestCasesPerSlice', dtaTestConfiguration.numberOfTestCasesPerSlice));
} else {
throw new Error(tl.loc('invalidTestBatchSize', batchSize));
}
}
// by default we set the distribution = number of agents
} else if (distributeOption && distributeOption === 'basedOnExecutionTime') {
dtaTestConfiguration.batchingType = models.BatchingType.TestExecutionTimeBased;
// flow if the batch type = based on agents/custom batching
const batchBasedOnExecutionTimeOption = tl.getInput('batchingBasedOnExecutionTimeOption');
if (batchBasedOnExecutionTimeOption && batchBasedOnExecutionTimeOption === 'customTimeBatchSize') {
const batchExecutionTimeInSec = parseInt(tl.getInput('customRunTimePerBatchValue'));
if (isNaN(batchExecutionTimeInSec) || batchExecutionTimeInSec <= 0) {
throw new Error(tl.loc('invalidRunTimePerBatch', batchExecutionTimeInSec));
}
dtaTestConfiguration.runningTimePerBatchInMs = 60 * 1000;
if (batchExecutionTimeInSec >= 60) {
dtaTestConfiguration.runningTimePerBatchInMs = batchExecutionTimeInSec * 1000;
console.log(tl.loc('RunTimePerBatch', dtaTestConfiguration.runningTimePerBatchInMs));
} else {
tl.warning(tl.loc('minimumRunTimePerBatchWarning', 60));
}
} else if (batchBasedOnExecutionTimeOption && batchBasedOnExecutionTimeOption === 'autoBatchSize') {
dtaTestConfiguration.runningTimePerBatchInMs = 0;
}
} else if (distributeOption && distributeOption === 'basedOnAssembly') {
dtaTestConfiguration.batchingType = models.BatchingType.AssemblyBased;
}
return 0;
}
示例7: detectMachineOS
private detectMachineOS(): string[] {
let osSuffix = [];
if (tl.osType().match(/^Win/)) {
let primary = "win-" + os.arch();
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
else {
let scriptPath = path.join(utilities.getCurrentDir(), 'externals', 'get-os-distro.sh');
utilities.setFileAttribute(scriptPath, "777");
let scriptRunner: trm.ToolRunner = tl.tool(tl.which(scriptPath, true));
let result: trm.IExecSyncResult = scriptRunner.execSync();
if (result.code != 0) {
throw tl.loc("getMachinePlatformFailed", result.error ? result.error.message : result.stderr);
}
let output: string = result.stdout;
let index;
if ((index = output.indexOf("Primary:")) >= 0) {
let primary = output.substr(index + "Primary:".length).split(os.EOL)[0];
osSuffix.push(primary);
console.log(tl.loc("PrimaryPlatform", primary));
}
if ((index = output.indexOf("Legacy:")) >= 0) {
let legacy = output.substr(index + "Legacy:".length).split(os.EOL)[0];
osSuffix.push(legacy);
console.log(tl.loc("LegacyPlatform", legacy));
}
if (osSuffix.length == 0) {
throw tl.loc("CouldNotDetectPlatform");
}
}
return osSuffix;
}
示例8: addCodeCoverageData
protected addCodeCoverageData(pomJson: any): Q.Promise<any[]> {
let _this = this;
if (!pomJson.project) {
Q.reject(tl.loc("InvalidBuildFile"));
}
let sourceData = _this.getSourceFilter();
let classData = _this.getClassData();
let reportPluginData = ccc.jacocoAntReport(_this.reportDir, classData, sourceData);
return Q.all([_this.addCodeCoveragePluginData(pomJson), _this.createReportFile(reportPluginData)]);
}
示例9: prependPathSafe
export function prependPathSafe(toolPath: string) {
// TODO task-lib 2.4.0: `assertAgent` is not in mock-task
// task.assertAgent('2.115.0');
console.log(task.loc('PrependPath', toolPath));
const newPath = toolPath + path.delimiter + process.env['PATH'];
task.debug('new Path: ' + newPath);
process.env['PATH'] = newPath;
// instruct the agent to set this path on future tasks
console.log('##vso[task.prependpath]' + toolPath);
}
示例10: run
async function run() {
try {
tl.setResourcePath(path.join(__dirname, 'task.json'));
const keystoreFile: string = tl.getTaskVariable('KEYSTORE_FILE_PATH');
if (keystoreFile && tl.exist(keystoreFile)) {
fs.unlinkSync(keystoreFile);
tl.debug('Deleted keystore file downloaded from the server: ' + keystoreFile);
}
} catch (err) {
tl.warning(tl.loc('DeleteKeystoreFileFailed', err));
}
}