azure-pipelines-task-lib
Advanced tools
Comparing version 2.8.0 to 3.0.0-preview
@@ -42,3 +42,3 @@ import vm = require('./vault'); | ||
*/ | ||
export declare function _getVariable(name: string): string; | ||
export declare function _getVariable(name: string): string | undefined; | ||
export declare function _getVariableKey(name: string): string; | ||
@@ -45,0 +45,0 @@ /** |
@@ -65,3 +65,3 @@ "use strict"; | ||
function _loadResJson(resjsonFile) { | ||
var resJson = null; | ||
var resJson; | ||
if (_exist(resjsonFile)) { | ||
@@ -78,3 +78,2 @@ var resjsonContent = fs.readFileSync(resjsonFile, 'utf8').toString(); | ||
_debug('unable to parse resjson with err: ' + err.message); | ||
resJson = null; | ||
} | ||
@@ -92,3 +91,3 @@ } | ||
if (resourceJson && resourceJson.hasOwnProperty('messages')) { | ||
var locResourceJson = null; | ||
var locResourceJson; | ||
// load up resource resjson for different culture | ||
@@ -272,3 +271,3 @@ var localizedResourceFile = path.join(path.dirname(resourceFile), 'Strings', 'resources.resjson'); | ||
try { | ||
exist = path && fs.statSync(path) != null; | ||
exist = !!(path && fs.statSync(path) != null); | ||
} | ||
@@ -822,3 +821,3 @@ catch (err) { | ||
global['_vsts_task_lib_proxy_bypass'] = proxyBypassHostsJson; | ||
global['_vsts_task_lib_proxy_password'] = _exposeTaskLibSecret('proxy', proxyPassword); | ||
global['_vsts_task_lib_proxy_password'] = _exposeTaskLibSecret('proxy', proxyPassword || ''); | ||
_debug('expose agent proxy configuration.'); | ||
@@ -845,3 +844,3 @@ global['_vsts_task_lib_proxy'] = true; | ||
global['_vsts_task_lib_cert_archive'] = clientCertArchive; | ||
global['_vsts_task_lib_cert_passphrase'] = _exposeTaskLibSecret('cert', clientCertPassword); | ||
global['_vsts_task_lib_cert_passphrase'] = _exposeTaskLibSecret('cert', clientCertPassword || ''); | ||
} | ||
@@ -848,0 +847,0 @@ if (ca || clientCert) { |
@@ -43,3 +43,3 @@ export interface TaskLibAnswerExecResult { | ||
} | ||
export declare type MockedCommand = 'checkPath' | 'cwd' | 'exec' | 'exist' | 'find' | 'findMatch' | 'ls' | 'osType' | 'rmRF' | 'stats' | 'which'; | ||
export declare type MockedCommand = keyof TaskLibAnswers; | ||
export declare class MockAnswers { | ||
@@ -46,0 +46,0 @@ private _answers; |
@@ -21,5 +21,6 @@ "use strict"; | ||
} | ||
if (this._answers[cmd][key]) { | ||
var cmd_answer = this._answers[cmd]; | ||
if (cmd_answer[key]) { | ||
debug('found mock response'); | ||
return this._answers[cmd][key]; | ||
return cmd_answer[key]; | ||
} | ||
@@ -29,5 +30,5 @@ if (key && process.env['MOCK_NORMALIZE_SLASHES'] === 'true') { | ||
var key2 = key.replace(/\\/g, "/"); | ||
if (this._answers[cmd][key2]) { | ||
if (cmd_answer[key2]) { | ||
debug('found mock response for normalized key'); | ||
return this._answers[cmd][key2]; | ||
return cmd_answer[key2]; | ||
} | ||
@@ -34,0 +35,0 @@ } |
@@ -5,3 +5,3 @@ import ma = require('./mock-answer'); | ||
_taskPath: string; | ||
_answers: ma.TaskLibAnswers; | ||
_answers: ma.TaskLibAnswers | undefined; | ||
_exports: { | ||
@@ -8,0 +8,0 @@ [key: string]: any; |
@@ -86,9 +86,9 @@ import Q = require('q'); | ||
export declare class TestPublisher { | ||
constructor(testRunner: any); | ||
testRunner: string; | ||
publish(resultFiles: any, mergeResults: any, platform: any, config: any, runTitle: any, publishRunAttachments: any): void; | ||
constructor(testRunner: string); | ||
publish(resultFiles?: string, mergeResults?: string, platform?: string, config?: string, runTitle?: string, publishRunAttachments?: string): void; | ||
} | ||
export declare class CodeCoveragePublisher { | ||
constructor(); | ||
publish(codeCoverageTool: any, summaryFileLocation: any, reportDirectory: any, additionalCodeCoverageFiles: any): void; | ||
publish(codeCoverageTool?: string, summaryFileLocation?: string, reportDirectory?: string, additionalCodeCoverageFiles?: string): void; | ||
} | ||
@@ -103,3 +103,3 @@ export declare class CodeCoverageEnabler { | ||
} | ||
export declare function getHttpProxyConfiguration(requestUrl?: string): task.ProxyConfiguration; | ||
export declare function getHttpCertConfiguration(): task.CertConfiguration; | ||
export declare function getHttpProxyConfiguration(requestUrl?: string): task.ProxyConfiguration | null; | ||
export declare function getHttpCertConfiguration(): task.CertConfiguration | null; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var path = require("path"); | ||
var os = require("os"); | ||
var task = require("./task"); | ||
@@ -15,19 +14,16 @@ var tcm = require("./taskcommand"); | ||
exports.setAnswers = setAnswers; | ||
//----------------------------------------------------- | ||
// Enums | ||
//----------------------------------------------------- | ||
module.exports.TaskResult = task.TaskResult; | ||
module.exports.TaskState = task.TaskState; | ||
module.exports.IssueType = task.IssueType; | ||
module.exports.ArtifactType = task.ArtifactType; | ||
module.exports.FieldType = task.FieldType; | ||
module.exports.Platform = task.Platform; | ||
//----------------------------------------------------- | ||
// General Helpers | ||
// Results and Exiting | ||
//----------------------------------------------------- | ||
var _outStream = process.stdout; | ||
var _errStream = process.stderr; | ||
function _writeError(str) { | ||
_errStream.write(str + os.EOL); | ||
} | ||
function _writeLine(str) { | ||
_outStream.write(str + os.EOL); | ||
} | ||
module.exports.setStdStream = task.setStdStream; | ||
module.exports.setErrStream = task.setErrStream; | ||
//----------------------------------------------------- | ||
// Results and Exiting | ||
//----------------------------------------------------- | ||
module.exports.setResult = task.setResult; | ||
@@ -92,25 +88,46 @@ //----------------------------------------------------- | ||
function FsStats() { | ||
this.m_isFile = false; | ||
this.m_isDirectory = false; | ||
this.m_isBlockDevice = false; | ||
this.m_isCharacterDevice = false; | ||
this.m_isSymbolicLink = false; | ||
this.m_isFIFO = false; | ||
this.m_isSocket = false; | ||
this.dev = 0; | ||
this.ino = 0; | ||
this.mode = 0; | ||
this.nlink = 0; | ||
this.uid = 0; | ||
this.gid = 0; | ||
this.rdev = 0; | ||
this.size = 0; | ||
this.blksize = 0; | ||
this.blocks = 0; | ||
this.atime = new Date(); | ||
this.mtime = new Date(); | ||
this.ctime = new Date(); | ||
this.birthtime = new Date(); | ||
} | ||
FsStats.prototype.setAnswers = function (mockResponses) { | ||
this.m_isFile = mockResponses['isFile'] || false; | ||
this.m_isDirectory = mockResponses['isDirectory'] || false; | ||
this.m_isBlockDevice = mockResponses['isBlockDevice'] || false; | ||
this.m_isCharacterDevice = mockResponses['isCharacterDevice'] || false; | ||
this.m_isSymbolicLink = mockResponses['isSymbolicLink'] || false; | ||
this.m_isFIFO = mockResponses['isFIFO'] || false; | ||
this.m_isSocket = mockResponses['isSocket'] || false; | ||
this.dev = mockResponses['dev']; | ||
this.ino = mockResponses['ino']; | ||
this.mode = mockResponses['mode']; | ||
this.nlink = mockResponses['nlink']; | ||
this.uid = mockResponses['uid']; | ||
this.gid = mockResponses['gid']; | ||
this.rdev = mockResponses['rdev']; | ||
this.size = mockResponses['size']; | ||
this.blksize = mockResponses['blksize']; | ||
this.blocks = mockResponses['blocks']; | ||
this.atime = mockResponses['atime']; | ||
this.mtime = mockResponses['mtime']; | ||
this.ctime = mockResponses['ctime']; | ||
this.m_isSocket = mockResponses['isSocket']; | ||
this.m_isFile = mockResponses['isFile'] || this.m_isFile; | ||
this.m_isDirectory = mockResponses['isDirectory'] || this.m_isDirectory; | ||
this.m_isBlockDevice = mockResponses['isBlockDevice'] || this.m_isBlockDevice; | ||
this.m_isCharacterDevice = mockResponses['isCharacterDevice'] || this.m_isCharacterDevice; | ||
this.m_isSymbolicLink = mockResponses['isSymbolicLink'] || this.m_isSymbolicLink; | ||
this.m_isFIFO = mockResponses['isFIFO'] || this.m_isFIFO; | ||
this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket; | ||
this.dev = mockResponses['dev'] || this.dev; | ||
this.ino = mockResponses['ino'] || this.ino; | ||
this.mode = mockResponses['mode'] || this.mode; | ||
this.nlink = mockResponses['nlink'] || this.nlink; | ||
this.uid = mockResponses['uid'] || this.uid; | ||
this.gid = mockResponses['gid'] || this.gid; | ||
this.rdev = mockResponses['rdev'] || this.rdev; | ||
this.size = mockResponses['size'] || this.size; | ||
this.blksize = mockResponses['blksize'] || this.blksize; | ||
this.blocks = mockResponses['blocks'] || this.blocks; | ||
this.atime = mockResponses['atime'] || this.atime; | ||
this.mtime = mockResponses['mtime'] || this.mtime; | ||
this.ctime = mockResponses['ctime'] || this.ctime; | ||
this.m_isSocket = mockResponses['isSocket'] || this.m_isSocket; | ||
}; | ||
@@ -117,0 +134,0 @@ FsStats.prototype.isFile = function () { |
export declare class MockTestRunner { | ||
constructor(testPath: string); | ||
constructor(testPath: string, taskJsonPath?: string); | ||
private _testPath; | ||
private _taskJsonPath; | ||
nodePath: string; | ||
stdout: string; | ||
stderr: string; | ||
cmdlines: any; | ||
cmdlines: {}; | ||
invokedToolCount: number; | ||
@@ -17,3 +19,11 @@ succeeded: boolean; | ||
stdErrContained(message: string): boolean; | ||
run(): void; | ||
run(nodeVersion?: number): void; | ||
private getNodePath; | ||
private getNodeVersion; | ||
private getTaskJsonPath; | ||
private downloadNode; | ||
private downloadFile; | ||
private downloadTarGz; | ||
private getPathToNodeExe; | ||
private getPlatform; | ||
} |
195
mock-test.js
@@ -5,10 +5,26 @@ "use strict"; | ||
var fs = require("fs"); | ||
var ncp = require("child_process"); | ||
var os = require("os"); | ||
var path = require("path"); | ||
var cmdm = require("./taskcommand"); | ||
var shelljs = require("shelljs"); | ||
var syncRequest = require("sync-request"); | ||
var COMMAND_TAG = '[command]'; | ||
var COMMAND_LENGTH = COMMAND_TAG.length; | ||
var downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, 'azure-pipelines-task-lib', '_download'); | ||
var MockTestRunner = /** @class */ (function () { | ||
function MockTestRunner(testPath) { | ||
function MockTestRunner(testPath, taskJsonPath) { | ||
this._testPath = ''; | ||
this._taskJsonPath = ''; | ||
this.nodePath = ''; | ||
this.stdout = ''; | ||
this.stderr = ''; | ||
this.cmdlines = {}; | ||
this.invokedToolCount = 0; | ||
this.succeeded = false; | ||
this.errorIssues = []; | ||
this.warningIssues = []; | ||
this._taskJsonPath = taskJsonPath || ''; | ||
this._testPath = testPath; | ||
this.nodePath = this.getNodePath(); | ||
} | ||
@@ -32,8 +48,8 @@ Object.defineProperty(MockTestRunner.prototype, "failed", { | ||
MockTestRunner.prototype.stdOutContained = function (message) { | ||
return this.stdout && this.stdout.indexOf(message) > 0; | ||
return this.stdout.indexOf(message) > 0; | ||
}; | ||
MockTestRunner.prototype.stdErrContained = function (message) { | ||
return this.stderr && this.stderr.indexOf(message) > 0; | ||
return this.stderr.indexOf(message) > 0; | ||
}; | ||
MockTestRunner.prototype.run = function () { | ||
MockTestRunner.prototype.run = function (nodeVersion) { | ||
var _this = this; | ||
@@ -45,8 +61,5 @@ this.cmdlines = {}; | ||
this.warningIssues = []; | ||
// we use node in the path. | ||
// if you want to test with a specific node, ensure it's in the path | ||
var nodePath = shelljs.which('node'); | ||
if (!nodePath) { | ||
console.error('Could not find node in path'); | ||
return; | ||
var nodePath = this.nodePath; | ||
if (nodeVersion) { | ||
nodePath = this.getNodePath(nodeVersion); | ||
} | ||
@@ -107,4 +120,166 @@ var spawn = cp.spawnSync(nodePath, [this._testPath]); | ||
}; | ||
// Returns a path to node.exe with the correct version for this task (based on if its node10 or node) | ||
MockTestRunner.prototype.getNodePath = function (nodeVersion) { | ||
var version = nodeVersion || this.getNodeVersion(); | ||
var downloadVersion; | ||
switch (version) { | ||
case 5: | ||
downloadVersion = 'v5.10.1'; | ||
break; | ||
case 6: | ||
downloadVersion = 'v6.10.3'; | ||
break; | ||
case 10: | ||
downloadVersion = 'v10.15.1'; | ||
break; | ||
default: | ||
throw new Error('Invalid node version, must be 5, 6, or 10 (received ' + version + ')'); | ||
} | ||
// Install node in home directory if it isn't already there. | ||
var downloadDestination = path.join(downloadDirectory, 'node' + version); | ||
var pathToExe = this.getPathToNodeExe(downloadVersion, downloadDestination); | ||
if (pathToExe) { | ||
return pathToExe; | ||
} | ||
else { | ||
return this.downloadNode(downloadVersion, downloadDestination); | ||
} | ||
}; | ||
// Determines the correct version of node to use based on the contents of the task's task.json. Defaults to Node 10. | ||
MockTestRunner.prototype.getNodeVersion = function () { | ||
var taskJsonPath = this.getTaskJsonPath(); | ||
if (!taskJsonPath) { | ||
console.warn('Unable to find task.json, defaulting to use Node 10'); | ||
return 10; | ||
} | ||
var taskJsonContents = fs.readFileSync(taskJsonPath, { encoding: 'utf-8' }); | ||
var taskJson = JSON.parse(taskJsonContents); | ||
var nodeVersionFound = false; | ||
var execution = taskJson['execution']; | ||
var keys = Object.keys(execution); | ||
for (var i = 0; i < keys.length; i++) { | ||
if (keys[i].toLowerCase() == 'node10') { | ||
// Prefer node 10 and return immediately. | ||
return 10; | ||
} | ||
else if (keys[i].toLowerCase() == 'node') { | ||
nodeVersionFound = true; | ||
} | ||
} | ||
if (!nodeVersionFound) { | ||
console.warn('Unable to determine execution type from task.json, defaulting to use Node 10'); | ||
return 10; | ||
} | ||
return 6; | ||
}; | ||
// Returns the path to the task.json for the task being tested. Returns null if unable to find it. | ||
// Searches by moving up the directory structure from the initial starting point and checking at each level. | ||
MockTestRunner.prototype.getTaskJsonPath = function () { | ||
if (this._taskJsonPath) { | ||
return this._taskJsonPath; | ||
} | ||
var curPath = this._testPath; | ||
var newPath = path.join(this._testPath, '..'); | ||
while (curPath != newPath) { | ||
curPath = newPath; | ||
var taskJsonPath = path.join(curPath, 'task.json'); | ||
if (fs.existsSync(taskJsonPath)) { | ||
return taskJsonPath; | ||
} | ||
newPath = path.join(curPath, '..'); | ||
} | ||
return ''; | ||
}; | ||
// Downloads the specified node version to the download destination. Returns a path to node.exe | ||
MockTestRunner.prototype.downloadNode = function (nodeVersion, downloadDestination) { | ||
shelljs.rm('-rf', downloadDestination); | ||
var nodeUrl = 'https://nodejs.org/dist'; | ||
var downloadPath = ''; | ||
switch (this.getPlatform()) { | ||
case 'darwin': | ||
this.downloadTarGz(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-x64.tar.gz', downloadDestination); | ||
downloadPath = path.join(downloadDestination, 'node-' + nodeVersion + '-darwin-x64', 'bin', 'node'); | ||
break; | ||
case 'linux': | ||
this.downloadTarGz(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-linux-x64.tar.gz', downloadDestination); | ||
downloadPath = path.join(downloadDestination, 'node-' + nodeVersion + '-linux-x64', 'bin', 'node'); | ||
break; | ||
case 'win32': | ||
this.downloadFile(nodeUrl + '/' + nodeVersion + '/win-x64/node.exe', downloadDestination, 'node.exe'); | ||
this.downloadFile(nodeUrl + '/' + nodeVersion + '/win-x64/node.lib', downloadDestination, 'node.lib'); | ||
downloadPath = path.join(downloadDestination, 'node.exe'); | ||
} | ||
// Write marker to indicate download completed. | ||
var marker = downloadDestination + '.completed'; | ||
fs.writeFileSync(marker, ''); | ||
return downloadPath; | ||
}; | ||
// Downloads file to the downloadDestination, making any necessary folders along the way. | ||
MockTestRunner.prototype.downloadFile = function (url, downloadDestination, fileName) { | ||
var filePath = path.join(downloadDestination, fileName); | ||
if (!url) { | ||
throw new Error('Parameter "url" must be set.'); | ||
} | ||
if (!downloadDestination) { | ||
throw new Error('Parameter "downloadDestination" must be set.'); | ||
} | ||
console.log('Downloading file:', url); | ||
shelljs.mkdir('-p', downloadDestination); | ||
var result = syncRequest('GET', url); | ||
fs.writeFileSync(filePath, result.getBody()); | ||
}; | ||
// Downloads tarGz to the download destination, making any necessary folders along the way. | ||
MockTestRunner.prototype.downloadTarGz = function (url, downloadDestination) { | ||
if (!url) { | ||
throw new Error('Parameter "url" must be set.'); | ||
} | ||
if (!downloadDestination) { | ||
throw new Error('Parameter "downloadDestination" must be set.'); | ||
} | ||
var tarGzName = 'node.tar.gz'; | ||
this.downloadFile(url, downloadDestination, tarGzName); | ||
// Extract file | ||
var originalCwd = process.cwd(); | ||
process.chdir(downloadDestination); | ||
try { | ||
ncp.execSync("tar -xzf \"" + path.join(downloadDestination, tarGzName) + "\""); | ||
} | ||
catch (_a) { | ||
throw new Error('Failed to unzip node tar.gz from ' + url); | ||
} | ||
finally { | ||
process.chdir(originalCwd); | ||
} | ||
}; | ||
// Checks if node is installed at downloadDestination. If it is, returns a path to node.exe, otherwise returns null. | ||
MockTestRunner.prototype.getPathToNodeExe = function (nodeVersion, downloadDestination) { | ||
var exePath = ''; | ||
switch (this.getPlatform()) { | ||
case 'darwin': | ||
exePath = path.join(downloadDestination, 'node-' + nodeVersion + '-darwin-x64', 'bin', 'node'); | ||
break; | ||
case 'linux': | ||
exePath = path.join(downloadDestination, 'node-' + nodeVersion + '-linux-x64', 'bin', 'node'); | ||
break; | ||
case 'win32': | ||
exePath = path.join(downloadDestination, 'node.exe'); | ||
} | ||
// Only use path if marker is found indicating download completed successfully (and not partially) | ||
var marker = downloadDestination + '.completed'; | ||
if (fs.existsSync(exePath) && fs.existsSync(marker)) { | ||
return exePath; | ||
} | ||
else { | ||
return ''; | ||
} | ||
}; | ||
MockTestRunner.prototype.getPlatform = function () { | ||
var platform = os.platform(); | ||
if (platform != 'darwin' && platform != 'linux' && platform != 'win32') { | ||
throw new Error('Unexpected platform: ' + platform); | ||
} | ||
return platform; | ||
}; | ||
return MockTestRunner; | ||
}()); | ||
exports.MockTestRunner = MockTestRunner; |
@@ -6,14 +6,14 @@ import Q = require('q'); | ||
export interface IExecOptions extends IExecSyncOptions { | ||
failOnStdErr: boolean; | ||
ignoreReturnCode: boolean; | ||
failOnStdErr?: boolean; | ||
ignoreReturnCode?: boolean; | ||
} | ||
export interface IExecSyncOptions { | ||
cwd: string; | ||
env: { | ||
cwd?: string; | ||
env?: { | ||
[key: string]: string; | ||
}; | ||
silent: boolean; | ||
silent?: boolean; | ||
outStream: NodeJS.WritableStream; | ||
errStream: NodeJS.WritableStream; | ||
windowsVerbatimArguments: boolean; | ||
windowsVerbatimArguments?: boolean; | ||
} | ||
@@ -28,3 +28,3 @@ export interface IExecSyncResult { | ||
export declare class ToolRunner extends events.EventEmitter { | ||
constructor(toolPath: any); | ||
constructor(toolPath: string); | ||
private toolPath; | ||
@@ -40,4 +40,4 @@ private args; | ||
private ignoreTempPath; | ||
exec(options: IExecOptions): Q.Promise<number>; | ||
execSync(options: IExecSyncOptions): IExecSyncResult; | ||
exec(options?: IExecOptions): Q.Promise<number>; | ||
execSync(options?: IExecSyncOptions): IExecSyncResult; | ||
} |
@@ -25,11 +25,2 @@ "use strict"; | ||
exports.setAnswers = setAnswers; | ||
var run = function (cmd, callback) { | ||
console.log('running: ' + cmd); | ||
var output = ''; | ||
try { | ||
} | ||
catch (err) { | ||
console.log(err.message); | ||
} | ||
}; | ||
; | ||
@@ -99,3 +90,3 @@ ; | ||
if (!val) { | ||
return; | ||
return this; | ||
} | ||
@@ -120,3 +111,3 @@ if (val instanceof Array) { | ||
if (!val) { | ||
return; | ||
return this; | ||
} | ||
@@ -123,0 +114,0 @@ this._debug(this.toolPath + ' arg: ' + val); |
{ | ||
"name": "azure-pipelines-task-lib", | ||
"version": "2.8.0", | ||
"version": "3.0.0-preview", | ||
"description": "Azure Pipelines Task SDK", | ||
@@ -5,0 +5,0 @@ "main": "./task.js", |
@@ -108,3 +108,3 @@ import Q = require('q'); | ||
*/ | ||
export declare function getInput(name: string, required?: boolean): string; | ||
export declare function getInput(name: string, required?: boolean): string | undefined; | ||
/** | ||
@@ -153,3 +153,3 @@ * Gets the value of an input and converts to a bool. Convenience. | ||
*/ | ||
export declare function getPathInput(name: string, required?: boolean, check?: boolean): string; | ||
export declare function getPathInput(name: string, required?: boolean, check?: boolean): string | undefined; | ||
/** | ||
@@ -173,3 +173,3 @@ * Gets the url for a service endpoint | ||
*/ | ||
export declare function getEndpointAuthorizationScheme(id: string, optional: boolean): string; | ||
export declare function getEndpointAuthorizationScheme(id: string, optional: boolean): string | undefined; | ||
/** | ||
@@ -184,3 +184,3 @@ * Gets the endpoint authorization parameter value for a service endpoint with specified key | ||
*/ | ||
export declare function getEndpointAuthorizationParameter(id: string, key: string, optional: boolean): string; | ||
export declare function getEndpointAuthorizationParameter(id: string, key: string, optional: boolean): string | undefined; | ||
/** | ||
@@ -206,3 +206,3 @@ * Interface for EndpointAuthorization | ||
*/ | ||
export declare function getEndpointAuthorization(id: string, optional: boolean): EndpointAuthorization; | ||
export declare function getEndpointAuthorization(id: string, optional: boolean): EndpointAuthorization | undefined; | ||
/** | ||
@@ -221,3 +221,3 @@ * Gets the name for a secure file | ||
*/ | ||
export declare function getSecureFileTicket(id: string): string; | ||
export declare function getSecureFileTicket(id: string): string | undefined; | ||
/** | ||
@@ -230,3 +230,3 @@ * Gets a variable value that is set by previous step from the same wrapper task. | ||
*/ | ||
export declare function getTaskVariable(name: string): string; | ||
export declare function getTaskVariable(name: string): string | undefined; | ||
/** | ||
@@ -478,3 +478,3 @@ * Sets a task variable which will only be available to subsequent steps belong to the same wrapper task. | ||
*/ | ||
export declare function getHttpProxyConfiguration(requestUrl?: string): ProxyConfiguration; | ||
export declare function getHttpProxyConfiguration(requestUrl?: string): ProxyConfiguration | null; | ||
export interface CertConfiguration { | ||
@@ -492,12 +492,11 @@ caFile?: string; | ||
*/ | ||
export declare function getHttpCertConfiguration(): CertConfiguration; | ||
export declare function getHttpCertConfiguration(): CertConfiguration | null; | ||
export declare class TestPublisher { | ||
constructor(testRunner: any); | ||
testRunner: string; | ||
publish(resultFiles: any, mergeResults: any, platform: any, config: any, runTitle: any, publishRunAttachments: any): void; | ||
publish(resultsFiles: any, mergeResults: any, platform: any, config: any, runTitle: any, publishRunAttachments: any, testRunSystem: any): void; | ||
constructor(testRunner: string); | ||
publish(resultFiles?: string, mergeResults?: string, platform?: string, config?: string, runTitle?: string, publishRunAttachments?: string, testRunSystem?: string): void; | ||
} | ||
export declare class CodeCoveragePublisher { | ||
constructor(); | ||
publish(codeCoverageTool: any, summaryFileLocation: any, reportDirectory: any, additionalCodeCoverageFiles: any): void; | ||
publish(codeCoverageTool?: string, summaryFileLocation?: string, reportDirectory?: string, additionalCodeCoverageFiles?: string): void; | ||
} | ||
@@ -504,0 +503,0 @@ export declare class CodeCoverageEnabler { |
@@ -9,5 +9,5 @@ import Q = require('q'); | ||
/** optional. whether to fail if output to stderr. defaults to false */ | ||
failOnStdErr: boolean; | ||
failOnStdErr?: boolean; | ||
/** optional. defaults to failing on non zero. ignore will not fail leaving it up to the caller */ | ||
ignoreReturnCode: boolean; | ||
ignoreReturnCode?: boolean; | ||
} | ||
@@ -19,13 +19,13 @@ /** | ||
/** optional working directory. defaults to current */ | ||
cwd: string; | ||
cwd?: string; | ||
/** optional envvar dictionary. defaults to current process's env */ | ||
env: { | ||
env?: { | ||
[key: string]: string; | ||
}; | ||
/** optional. defaults to false */ | ||
silent: boolean; | ||
silent?: boolean; | ||
outStream: stream.Writable; | ||
errStream: stream.Writable; | ||
/** optional. foo.whether to skip quoting/escaping arguments if needed. defaults to false. */ | ||
windowsVerbatimArguments: boolean; | ||
windowsVerbatimArguments?: boolean; | ||
} | ||
@@ -46,3 +46,3 @@ /** | ||
export declare class ToolRunner extends events.EventEmitter { | ||
constructor(toolPath: any); | ||
constructor(toolPath: string); | ||
private toolPath; | ||
@@ -49,0 +49,0 @@ private args; |
@@ -22,4 +22,2 @@ "use strict"; | ||
var fs = require("fs"); | ||
; | ||
; | ||
var ToolRunner = /** @class */ (function (_super) { | ||
@@ -402,2 +400,3 @@ __extends(ToolRunner, _super); | ||
ToolRunner.prototype._getSpawnOptions = function (options) { | ||
options = options || {}; | ||
var result = {}; | ||
@@ -416,3 +415,3 @@ result.cwd = options.cwd; | ||
}; | ||
ToolRunner.prototype.execWithPiping = function (options) { | ||
ToolRunner.prototype.execWithPiping = function (pipeOutputToTool, options) { | ||
var _this = this; | ||
@@ -426,8 +425,8 @@ var defer = Q.defer(); | ||
var success = true; | ||
options = this._cloneExecOptions(options); | ||
if (!options.silent) { | ||
options.outStream.write(this._getCommandString(options) + os.EOL); | ||
var optionsNonNull = this._cloneExecOptions(options); | ||
if (!optionsNonNull.silent) { | ||
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); | ||
} | ||
var cp; | ||
var toolPath = this.toolPath; | ||
var toolPath = pipeOutputToTool.toolPath; | ||
var toolPathFirst; | ||
@@ -440,3 +439,2 @@ var successFirst = true; | ||
var error; | ||
toolPath = this.pipeOutputToTool.toolPath; | ||
toolPathFirst = this.toolPath; | ||
@@ -447,5 +445,5 @@ // Following node documentation example from this link on how to pipe output of one process to another | ||
waitingEvents++; | ||
var cpFirst = child.spawn(this._getSpawnFileName(), this._getSpawnArgs(options), this._getSpawnOptions(options)); | ||
var cpFirst = child.spawn(this._getSpawnFileName(), this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(optionsNonNull)); | ||
waitingEvents++; | ||
cp = child.spawn(this.pipeOutputToTool._getSpawnFileName(), this.pipeOutputToTool._getSpawnArgs(options), this.pipeOutputToTool._getSpawnOptions(options)); | ||
cp = child.spawn(pipeOutputToTool._getSpawnFileName(), pipeOutputToTool._getSpawnArgs(optionsNonNull), pipeOutputToTool._getSpawnOptions(optionsNonNull)); | ||
fileStream = this.pipeOutputToFile ? fs.createWriteStream(this.pipeOutputToFile) : null; | ||
@@ -497,5 +495,5 @@ if (fileStream) { | ||
} | ||
successFirst = !options.failOnStdErr; | ||
if (!options.silent) { | ||
var s = options.failOnStdErr ? options.errStream : options.outStream; | ||
successFirst = !optionsNonNull.failOnStdErr; | ||
if (!optionsNonNull.silent) { | ||
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; | ||
s.write(data); | ||
@@ -517,3 +515,3 @@ } | ||
waitingEvents--; //first process is complete | ||
if (code != 0 && !options.ignoreReturnCode) { | ||
if (code != 0 && !optionsNonNull.ignoreReturnCode) { | ||
successFirst = false; | ||
@@ -540,4 +538,4 @@ returnCodeFirst = code; | ||
_this.emit('stdout', data); | ||
if (!options.silent) { | ||
options.outStream.write(data); | ||
if (!optionsNonNull.silent) { | ||
optionsNonNull.outStream.write(data); | ||
} | ||
@@ -551,5 +549,5 @@ _this._processLineBuffer(data, stdbuffer, function (line) { | ||
_this.emit('stderr', data); | ||
success = !options.failOnStdErr; | ||
if (!options.silent) { | ||
var s = options.failOnStdErr ? options.errStream : options.outStream; | ||
success = !optionsNonNull.failOnStdErr; | ||
if (!optionsNonNull.silent) { | ||
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; | ||
s.write(data); | ||
@@ -578,3 +576,3 @@ } | ||
} | ||
if (code != 0 && !options.ignoreReturnCode) { | ||
if (code != 0 && !optionsNonNull.ignoreReturnCode) { | ||
success = false; | ||
@@ -610,3 +608,3 @@ } | ||
if (!val) { | ||
return; | ||
return this; | ||
} | ||
@@ -633,3 +631,3 @@ if (val instanceof Array) { | ||
if (!val) { | ||
return; | ||
return this; | ||
} | ||
@@ -678,3 +676,3 @@ this._debug(this.toolPath + ' arg: ' + val); | ||
if (this.pipeOutputToTool) { | ||
return this.execWithPiping(options); | ||
return this.execWithPiping(this.pipeOutputToTool, options); | ||
} | ||
@@ -687,16 +685,16 @@ var defer = Q.defer(); | ||
}); | ||
options = this._cloneExecOptions(options); | ||
if (!options.silent) { | ||
options.outStream.write(this._getCommandString(options) + os.EOL); | ||
var optionsNonNull = this._cloneExecOptions(options); | ||
if (!optionsNonNull.silent) { | ||
optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os.EOL); | ||
} | ||
var state = new ExecState(options, this.toolPath); | ||
var state = new ExecState(optionsNonNull, this.toolPath); | ||
state.on('debug', function (message) { | ||
_this._debug(message); | ||
}); | ||
var cp = child.spawn(this._getSpawnFileName(), this._getSpawnArgs(options), this._getSpawnOptions(options)); | ||
var cp = child.spawn(this._getSpawnFileName(), this._getSpawnArgs(optionsNonNull), this._getSpawnOptions(options)); | ||
var stdbuffer = ''; | ||
cp.stdout.on('data', function (data) { | ||
_this.emit('stdout', data); | ||
if (!options.silent) { | ||
options.outStream.write(data); | ||
if (!optionsNonNull.silent) { | ||
optionsNonNull.outStream.write(data); | ||
} | ||
@@ -711,4 +709,4 @@ _this._processLineBuffer(data, stdbuffer, function (line) { | ||
_this.emit('stderr', data); | ||
if (!options.silent) { | ||
var s = options.failOnStdErr ? options.errStream : options.outStream; | ||
if (!optionsNonNull.silent) { | ||
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream : optionsNonNull.outStream; | ||
s.write(data); | ||
@@ -768,3 +766,2 @@ } | ||
var _this = this; | ||
var defer = Q.defer(); | ||
this._debug('exec tool: ' + this.toolPath); | ||
@@ -788,4 +785,4 @@ this._debug('arguments:'); | ||
var res = { code: r.status, error: r.error }; | ||
res.stdout = (r.stdout) ? r.stdout.toString() : null; | ||
res.stderr = (r.stderr) ? r.stderr.toString() : null; | ||
res.stdout = (r.stdout) ? r.stdout.toString() : ''; | ||
res.stderr = (r.stderr) ? r.stderr.toString() : ''; | ||
return res; | ||
@@ -801,2 +798,3 @@ }; | ||
_this.delay = 10000; // 10 seconds | ||
_this.timeout = null; | ||
if (!toolPath) { | ||
@@ -803,0 +801,0 @@ throw new Error('toolPath must not be empty'); |
@@ -7,5 +7,5 @@ export declare class Vault { | ||
storeSecret(name: string, data: string): boolean; | ||
retrieveSecret(name: string): string; | ||
retrieveSecret(name: string): string | undefined; | ||
private getKey; | ||
private genKey; | ||
} |
@@ -45,3 +45,3 @@ "use strict"; | ||
Vault.prototype.retrieveSecret = function (name) { | ||
var secret = null; | ||
var secret; | ||
name = (name || '').toLowerCase(); | ||
@@ -48,0 +48,0 @@ if (this._store.hasOwnProperty(name)) { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
342309
5953
1
50
3