azure-pipelines-task-lib 3.3.1 → 4.0.0-preview
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -22
- package/README.md +74 -74
- package/Strings/resources.resjson/de-DE/resources.resjson +34 -34
- package/Strings/resources.resjson/es-ES/resources.resjson +34 -34
- package/Strings/resources.resjson/fr-FR/resources.resjson +34 -34
- package/Strings/resources.resjson/ja-JP/resources.resjson +34 -34
- package/ThirdPartyNotice.txt +1114 -1114
- package/internal.d.ts +130 -130
- package/internal.js +885 -885
- package/lib.json +37 -37
- package/mock-answer.d.ts +55 -55
- package/mock-answer.js +41 -41
- package/mock-run.d.ts +44 -44
- package/mock-run.js +92 -92
- package/mock-task.d.ts +111 -111
- package/mock-task.js +447 -447
- package/mock-test.d.ts +28 -28
- package/mock-test.js +298 -298
- package/mock-toolrunner.d.ts +41 -41
- package/mock-toolrunner.js +268 -268
- package/package.json +49 -49
- package/task.d.ts +718 -718
- package/task.js +2003 -2003
- package/taskcommand.d.ts +10 -10
- package/taskcommand.js +103 -103
- package/toolrunner.d.ts +159 -159
- package/toolrunner.js +967 -967
- package/vault.d.ts +10 -10
- package/vault.js +71 -71
package/lib.json
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
{
|
|
2
|
-
"messages": {
|
|
3
|
-
"LIB_UnhandledEx": "Unhandled: %s",
|
|
4
|
-
"LIB_FailOnCode": "Failure return code: %d",
|
|
5
|
-
"LIB_MkdirFailed": "Unable to create directory '%s'. %s",
|
|
6
|
-
"LIB_MkdirFailedFileExists": "Unable to create directory '%s'. Conflicting file exists: '%s'",
|
|
7
|
-
"LIB_MkdirFailedInvalidDriveRoot": "Unable to create directory '%s'. Root directory does not exist: '%s'",
|
|
8
|
-
"LIB_MkdirFailedInvalidShare": "Unable to create directory '%s'. Unable to verify the directory exists: '%s'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.",
|
|
9
|
-
"LIB_MultilineSecret": "Secrets cannot contain multiple lines",
|
|
10
|
-
"LIB_ProcessError": "There was an error when attempting to execute the process '%s'. This may indicate the process failed to start. Error: %s",
|
|
11
|
-
"LIB_ProcessExitCode": "The process '%s' failed with exit code %s",
|
|
12
|
-
"LIB_ProcessStderr": "The process '%s' failed because one or more lines were written to the STDERR stream",
|
|
13
|
-
"LIB_ReturnCode": "Return code: %d",
|
|
14
|
-
"LIB_ResourceFileNotExist": "Resource file doesn\\'t exist: %s",
|
|
15
|
-
"LIB_ResourceFileAlreadySet": "Resource file has already set to: %s",
|
|
16
|
-
"LIB_ResourceFileNotSet": "Resource file haven\\'t set, can\\'t find loc string for key: %s",
|
|
17
|
-
"LIB_StdioNotClosed": "The STDIO streams did not close within %s seconds of the exit event from process '%s'. This may indicate a child process inherited the STDIO streams and has not yet exited.",
|
|
18
|
-
"LIB_WhichNotFound_Linux": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.",
|
|
19
|
-
"LIB_WhichNotFound_Win": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.",
|
|
20
|
-
"LIB_LocStringNotFound": "Can\\'t find loc string for key: %s",
|
|
21
|
-
"LIB_ParameterIsRequired": "%s not supplied",
|
|
22
|
-
"LIB_InputRequired": "Input required: %s",
|
|
23
|
-
"LIB_InvalidPattern": "Invalid pattern: '%s'",
|
|
24
|
-
"LIB_EndpointNotExist": "Endpoint not present: %s",
|
|
25
|
-
"LIB_EndpointDataNotExist": "Endpoint data parameter %s not present: %s",
|
|
26
|
-
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
|
27
|
-
"LIB_InvalidEndpointAuth": "Invalid endpoint auth: %s",
|
|
28
|
-
"LIB_InvalidSecureFilesInput": "Invalid secure file input: %s",
|
|
29
|
-
"LIB_PathNotFound": "Not found %s: %s",
|
|
30
|
-
"LIB_PathHasNullByte": "Path cannot contain null bytes",
|
|
31
|
-
"LIB_OperationFailed": "Failed %s: %s",
|
|
32
|
-
"LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
|
|
33
|
-
"LIB_MergeTestResultNotSupported": "Merging test results from multiple files to one test run is not supported on this version of build agent for OSX/Linux, each test result file will be published as a separate test run in VSO/TFS.",
|
|
34
|
-
"LIB_PlatformNotSupported": "Platform not supported: %s",
|
|
35
|
-
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"messages": {
|
|
3
|
+
"LIB_UnhandledEx": "Unhandled: %s",
|
|
4
|
+
"LIB_FailOnCode": "Failure return code: %d",
|
|
5
|
+
"LIB_MkdirFailed": "Unable to create directory '%s'. %s",
|
|
6
|
+
"LIB_MkdirFailedFileExists": "Unable to create directory '%s'. Conflicting file exists: '%s'",
|
|
7
|
+
"LIB_MkdirFailedInvalidDriveRoot": "Unable to create directory '%s'. Root directory does not exist: '%s'",
|
|
8
|
+
"LIB_MkdirFailedInvalidShare": "Unable to create directory '%s'. Unable to verify the directory exists: '%s'. If directory is a file share, please verify the share name is correct, the share is online, and the current process has permission to access the share.",
|
|
9
|
+
"LIB_MultilineSecret": "Secrets cannot contain multiple lines",
|
|
10
|
+
"LIB_ProcessError": "There was an error when attempting to execute the process '%s'. This may indicate the process failed to start. Error: %s",
|
|
11
|
+
"LIB_ProcessExitCode": "The process '%s' failed with exit code %s",
|
|
12
|
+
"LIB_ProcessStderr": "The process '%s' failed because one or more lines were written to the STDERR stream",
|
|
13
|
+
"LIB_ReturnCode": "Return code: %d",
|
|
14
|
+
"LIB_ResourceFileNotExist": "Resource file doesn\\'t exist: %s",
|
|
15
|
+
"LIB_ResourceFileAlreadySet": "Resource file has already set to: %s",
|
|
16
|
+
"LIB_ResourceFileNotSet": "Resource file haven\\'t set, can\\'t find loc string for key: %s",
|
|
17
|
+
"LIB_StdioNotClosed": "The STDIO streams did not close within %s seconds of the exit event from process '%s'. This may indicate a child process inherited the STDIO streams and has not yet exited.",
|
|
18
|
+
"LIB_WhichNotFound_Linux": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.",
|
|
19
|
+
"LIB_WhichNotFound_Win": "Unable to locate executable file: '%s'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.",
|
|
20
|
+
"LIB_LocStringNotFound": "Can\\'t find loc string for key: %s",
|
|
21
|
+
"LIB_ParameterIsRequired": "%s not supplied",
|
|
22
|
+
"LIB_InputRequired": "Input required: %s",
|
|
23
|
+
"LIB_InvalidPattern": "Invalid pattern: '%s'",
|
|
24
|
+
"LIB_EndpointNotExist": "Endpoint not present: %s",
|
|
25
|
+
"LIB_EndpointDataNotExist": "Endpoint data parameter %s not present: %s",
|
|
26
|
+
"LIB_EndpointAuthNotExist": "Endpoint auth data not present: %s",
|
|
27
|
+
"LIB_InvalidEndpointAuth": "Invalid endpoint auth: %s",
|
|
28
|
+
"LIB_InvalidSecureFilesInput": "Invalid secure file input: %s",
|
|
29
|
+
"LIB_PathNotFound": "Not found %s: %s",
|
|
30
|
+
"LIB_PathHasNullByte": "Path cannot contain null bytes",
|
|
31
|
+
"LIB_OperationFailed": "Failed %s: %s",
|
|
32
|
+
"LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
|
|
33
|
+
"LIB_MergeTestResultNotSupported": "Merging test results from multiple files to one test run is not supported on this version of build agent for OSX/Linux, each test result file will be published as a separate test run in VSO/TFS.",
|
|
34
|
+
"LIB_PlatformNotSupported": "Platform not supported: %s",
|
|
35
|
+
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/mock-answer.d.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
import * as task from './task';
|
|
2
|
-
export interface TaskLibAnswerExecResult {
|
|
3
|
-
code: number;
|
|
4
|
-
stdout?: string;
|
|
5
|
-
stderr?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface TaskLibAnswers {
|
|
8
|
-
checkPath?: {
|
|
9
|
-
[key: string]: boolean;
|
|
10
|
-
};
|
|
11
|
-
cwd?: {
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
};
|
|
14
|
-
exec?: {
|
|
15
|
-
[key: string]: TaskLibAnswerExecResult;
|
|
16
|
-
};
|
|
17
|
-
exist?: {
|
|
18
|
-
[key: string]: boolean;
|
|
19
|
-
};
|
|
20
|
-
find?: {
|
|
21
|
-
[key: string]: string[];
|
|
22
|
-
};
|
|
23
|
-
findMatch?: {
|
|
24
|
-
[key: string]: string[];
|
|
25
|
-
};
|
|
26
|
-
getPlatform?: {
|
|
27
|
-
[key: string]: task.Platform;
|
|
28
|
-
};
|
|
29
|
-
legacyFindFiles?: {
|
|
30
|
-
[key: string]: string[];
|
|
31
|
-
};
|
|
32
|
-
ls?: {
|
|
33
|
-
[key: string]: string;
|
|
34
|
-
};
|
|
35
|
-
osType?: {
|
|
36
|
-
[key: string]: string;
|
|
37
|
-
};
|
|
38
|
-
rmRF?: {
|
|
39
|
-
[key: string]: {
|
|
40
|
-
success: boolean;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
stats?: {
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
};
|
|
46
|
-
which?: {
|
|
47
|
-
[key: string]: string;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export declare type MockedCommand = keyof TaskLibAnswers;
|
|
51
|
-
export declare class MockAnswers {
|
|
52
|
-
private _answers;
|
|
53
|
-
initialize(answers: TaskLibAnswers): void;
|
|
54
|
-
getResponse(cmd: MockedCommand, key: string, debug: (message: string) => void): any;
|
|
55
|
-
}
|
|
1
|
+
import * as task from './task';
|
|
2
|
+
export interface TaskLibAnswerExecResult {
|
|
3
|
+
code: number;
|
|
4
|
+
stdout?: string;
|
|
5
|
+
stderr?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TaskLibAnswers {
|
|
8
|
+
checkPath?: {
|
|
9
|
+
[key: string]: boolean;
|
|
10
|
+
};
|
|
11
|
+
cwd?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
exec?: {
|
|
15
|
+
[key: string]: TaskLibAnswerExecResult;
|
|
16
|
+
};
|
|
17
|
+
exist?: {
|
|
18
|
+
[key: string]: boolean;
|
|
19
|
+
};
|
|
20
|
+
find?: {
|
|
21
|
+
[key: string]: string[];
|
|
22
|
+
};
|
|
23
|
+
findMatch?: {
|
|
24
|
+
[key: string]: string[];
|
|
25
|
+
};
|
|
26
|
+
getPlatform?: {
|
|
27
|
+
[key: string]: task.Platform;
|
|
28
|
+
};
|
|
29
|
+
legacyFindFiles?: {
|
|
30
|
+
[key: string]: string[];
|
|
31
|
+
};
|
|
32
|
+
ls?: {
|
|
33
|
+
[key: string]: string;
|
|
34
|
+
};
|
|
35
|
+
osType?: {
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
};
|
|
38
|
+
rmRF?: {
|
|
39
|
+
[key: string]: {
|
|
40
|
+
success: boolean;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
stats?: {
|
|
44
|
+
[key: string]: any;
|
|
45
|
+
};
|
|
46
|
+
which?: {
|
|
47
|
+
[key: string]: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare type MockedCommand = keyof TaskLibAnswers;
|
|
51
|
+
export declare class MockAnswers {
|
|
52
|
+
private _answers;
|
|
53
|
+
initialize(answers: TaskLibAnswers): void;
|
|
54
|
+
getResponse(cmd: MockedCommand, key: string, debug: (message: string) => void): any;
|
|
55
|
+
}
|
package/mock-answer.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockAnswers = void 0;
|
|
4
|
-
var MockAnswers = /** @class */ (function () {
|
|
5
|
-
function MockAnswers() {
|
|
6
|
-
}
|
|
7
|
-
MockAnswers.prototype.initialize = function (answers) {
|
|
8
|
-
if (!answers) {
|
|
9
|
-
throw new Error('Answers not supplied');
|
|
10
|
-
}
|
|
11
|
-
this._answers = answers;
|
|
12
|
-
};
|
|
13
|
-
MockAnswers.prototype.getResponse = function (cmd, key, debug) {
|
|
14
|
-
debug("looking up mock answers for " + JSON.stringify(cmd) + ", key '" + JSON.stringify(key) + "'");
|
|
15
|
-
if (!this._answers) {
|
|
16
|
-
throw new Error('Must initialize');
|
|
17
|
-
}
|
|
18
|
-
if (!this._answers[cmd]) {
|
|
19
|
-
debug("no mock responses registered for " + JSON.stringify(cmd));
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
var cmd_answer = this._answers[cmd];
|
|
23
|
-
//use this construction to avoid falsy zero
|
|
24
|
-
if (cmd_answer[key] != null) {
|
|
25
|
-
debug('found mock response');
|
|
26
|
-
return cmd_answer[key];
|
|
27
|
-
}
|
|
28
|
-
if (key && process.env['MOCK_NORMALIZE_SLASHES'] === 'true') {
|
|
29
|
-
// try normalizing the slashes
|
|
30
|
-
var key2 = key.replace(/\\/g, "/");
|
|
31
|
-
if (cmd_answer[key2]) {
|
|
32
|
-
debug('found mock response for normalized key');
|
|
33
|
-
return cmd_answer[key2];
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
debug('mock response not found');
|
|
37
|
-
return null;
|
|
38
|
-
};
|
|
39
|
-
return MockAnswers;
|
|
40
|
-
}());
|
|
41
|
-
exports.MockAnswers = MockAnswers;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MockAnswers = void 0;
|
|
4
|
+
var MockAnswers = /** @class */ (function () {
|
|
5
|
+
function MockAnswers() {
|
|
6
|
+
}
|
|
7
|
+
MockAnswers.prototype.initialize = function (answers) {
|
|
8
|
+
if (!answers) {
|
|
9
|
+
throw new Error('Answers not supplied');
|
|
10
|
+
}
|
|
11
|
+
this._answers = answers;
|
|
12
|
+
};
|
|
13
|
+
MockAnswers.prototype.getResponse = function (cmd, key, debug) {
|
|
14
|
+
debug("looking up mock answers for " + JSON.stringify(cmd) + ", key '" + JSON.stringify(key) + "'");
|
|
15
|
+
if (!this._answers) {
|
|
16
|
+
throw new Error('Must initialize');
|
|
17
|
+
}
|
|
18
|
+
if (!this._answers[cmd]) {
|
|
19
|
+
debug("no mock responses registered for " + JSON.stringify(cmd));
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
var cmd_answer = this._answers[cmd];
|
|
23
|
+
//use this construction to avoid falsy zero
|
|
24
|
+
if (cmd_answer[key] != null) {
|
|
25
|
+
debug('found mock response');
|
|
26
|
+
return cmd_answer[key];
|
|
27
|
+
}
|
|
28
|
+
if (key && process.env['MOCK_NORMALIZE_SLASHES'] === 'true') {
|
|
29
|
+
// try normalizing the slashes
|
|
30
|
+
var key2 = key.replace(/\\/g, "/");
|
|
31
|
+
if (cmd_answer[key2]) {
|
|
32
|
+
debug('found mock response for normalized key');
|
|
33
|
+
return cmd_answer[key2];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
debug('mock response not found');
|
|
37
|
+
return null;
|
|
38
|
+
};
|
|
39
|
+
return MockAnswers;
|
|
40
|
+
}());
|
|
41
|
+
exports.MockAnswers = MockAnswers;
|
package/mock-run.d.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import ma = require('./mock-answer');
|
|
2
|
-
export declare class TaskMockRunner {
|
|
3
|
-
constructor(taskPath: string);
|
|
4
|
-
_taskPath: string;
|
|
5
|
-
_answers: ma.TaskLibAnswers | undefined;
|
|
6
|
-
_exports: {
|
|
7
|
-
[key: string]: any;
|
|
8
|
-
};
|
|
9
|
-
_moduleCount: number;
|
|
10
|
-
setInput(name: string, val: string): void;
|
|
11
|
-
setVariableName(name: string, val: string, isSecret?: boolean): void;
|
|
12
|
-
/**
|
|
13
|
-
* Register answers for the mock "azure-pipelines-task-lib/task" instance.
|
|
14
|
-
*
|
|
15
|
-
* @param answers Answers to be returned when the task lib functions are called.
|
|
16
|
-
*/
|
|
17
|
-
setAnswers(answers: ma.TaskLibAnswers): void;
|
|
18
|
-
/**
|
|
19
|
-
* Register a mock module. When require() is called for the module name,
|
|
20
|
-
* the mock implementation will be returned instead.
|
|
21
|
-
*
|
|
22
|
-
* @param modName Module name to override.
|
|
23
|
-
* @param val Mock implementation of the module.
|
|
24
|
-
* @returns void
|
|
25
|
-
*/
|
|
26
|
-
registerMock(modName: string, mod: any): void;
|
|
27
|
-
/**
|
|
28
|
-
* Registers an override for a specific function on the mock "azure-pipelines-task-lib/task" instance.
|
|
29
|
-
* This can be used in conjunction with setAnswers(), for cases where additional runtime
|
|
30
|
-
* control is needed for a specific function.
|
|
31
|
-
*
|
|
32
|
-
* @param key Function or field to override.
|
|
33
|
-
* @param val Function or field value.
|
|
34
|
-
* @returns void
|
|
35
|
-
*/
|
|
36
|
-
registerMockExport(key: string, val: any): void;
|
|
37
|
-
/**
|
|
38
|
-
* Runs a task script.
|
|
39
|
-
*
|
|
40
|
-
* @param noMockTask Indicates whether to mock "azure-pipelines-task-lib/task". Default is to mock.
|
|
41
|
-
* @returns void
|
|
42
|
-
*/
|
|
43
|
-
run(noMockTask?: boolean): void;
|
|
44
|
-
}
|
|
1
|
+
import ma = require('./mock-answer');
|
|
2
|
+
export declare class TaskMockRunner {
|
|
3
|
+
constructor(taskPath: string);
|
|
4
|
+
_taskPath: string;
|
|
5
|
+
_answers: ma.TaskLibAnswers | undefined;
|
|
6
|
+
_exports: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
_moduleCount: number;
|
|
10
|
+
setInput(name: string, val: string): void;
|
|
11
|
+
setVariableName(name: string, val: string, isSecret?: boolean): void;
|
|
12
|
+
/**
|
|
13
|
+
* Register answers for the mock "azure-pipelines-task-lib/task" instance.
|
|
14
|
+
*
|
|
15
|
+
* @param answers Answers to be returned when the task lib functions are called.
|
|
16
|
+
*/
|
|
17
|
+
setAnswers(answers: ma.TaskLibAnswers): void;
|
|
18
|
+
/**
|
|
19
|
+
* Register a mock module. When require() is called for the module name,
|
|
20
|
+
* the mock implementation will be returned instead.
|
|
21
|
+
*
|
|
22
|
+
* @param modName Module name to override.
|
|
23
|
+
* @param val Mock implementation of the module.
|
|
24
|
+
* @returns void
|
|
25
|
+
*/
|
|
26
|
+
registerMock(modName: string, mod: any): void;
|
|
27
|
+
/**
|
|
28
|
+
* Registers an override for a specific function on the mock "azure-pipelines-task-lib/task" instance.
|
|
29
|
+
* This can be used in conjunction with setAnswers(), for cases where additional runtime
|
|
30
|
+
* control is needed for a specific function.
|
|
31
|
+
*
|
|
32
|
+
* @param key Function or field to override.
|
|
33
|
+
* @param val Function or field value.
|
|
34
|
+
* @returns void
|
|
35
|
+
*/
|
|
36
|
+
registerMockExport(key: string, val: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* Runs a task script.
|
|
39
|
+
*
|
|
40
|
+
* @param noMockTask Indicates whether to mock "azure-pipelines-task-lib/task". Default is to mock.
|
|
41
|
+
* @returns void
|
|
42
|
+
*/
|
|
43
|
+
run(noMockTask?: boolean): void;
|
|
44
|
+
}
|
package/mock-run.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TaskMockRunner = void 0;
|
|
4
|
-
var mockery = require("mockery");
|
|
5
|
-
var im = require("./internal");
|
|
6
|
-
var TaskMockRunner = /** @class */ (function () {
|
|
7
|
-
function TaskMockRunner(taskPath) {
|
|
8
|
-
this._exports = {};
|
|
9
|
-
this._moduleCount = 0;
|
|
10
|
-
this._taskPath = taskPath;
|
|
11
|
-
}
|
|
12
|
-
TaskMockRunner.prototype.setInput = function (name, val) {
|
|
13
|
-
var key = im._getVariableKey(name);
|
|
14
|
-
process.env['INPUT_' + key] = val;
|
|
15
|
-
};
|
|
16
|
-
TaskMockRunner.prototype.setVariableName = function (name, val, isSecret) {
|
|
17
|
-
var key = im._getVariableKey(name);
|
|
18
|
-
if (isSecret) {
|
|
19
|
-
process.env['SECRET_' + key] = val;
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
process.env['VSTS_TASKVARIABLE_' + key] = val;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Register answers for the mock "azure-pipelines-task-lib/task" instance.
|
|
27
|
-
*
|
|
28
|
-
* @param answers Answers to be returned when the task lib functions are called.
|
|
29
|
-
*/
|
|
30
|
-
TaskMockRunner.prototype.setAnswers = function (answers) {
|
|
31
|
-
this._answers = answers;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Register a mock module. When require() is called for the module name,
|
|
35
|
-
* the mock implementation will be returned instead.
|
|
36
|
-
*
|
|
37
|
-
* @param modName Module name to override.
|
|
38
|
-
* @param val Mock implementation of the module.
|
|
39
|
-
* @returns void
|
|
40
|
-
*/
|
|
41
|
-
TaskMockRunner.prototype.registerMock = function (modName, mod) {
|
|
42
|
-
this._moduleCount++;
|
|
43
|
-
mockery.registerMock(modName, mod);
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Registers an override for a specific function on the mock "azure-pipelines-task-lib/task" instance.
|
|
47
|
-
* This can be used in conjunction with setAnswers(), for cases where additional runtime
|
|
48
|
-
* control is needed for a specific function.
|
|
49
|
-
*
|
|
50
|
-
* @param key Function or field to override.
|
|
51
|
-
* @param val Function or field value.
|
|
52
|
-
* @returns void
|
|
53
|
-
*/
|
|
54
|
-
TaskMockRunner.prototype.registerMockExport = function (key, val) {
|
|
55
|
-
this._exports[key] = val;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Runs a task script.
|
|
59
|
-
*
|
|
60
|
-
* @param noMockTask Indicates whether to mock "azure-pipelines-task-lib/task". Default is to mock.
|
|
61
|
-
* @returns void
|
|
62
|
-
*/
|
|
63
|
-
TaskMockRunner.prototype.run = function (noMockTask) {
|
|
64
|
-
var _this = this;
|
|
65
|
-
// determine whether to enable mockery
|
|
66
|
-
if (!noMockTask || this._moduleCount) {
|
|
67
|
-
mockery.enable({ warnOnUnregistered: false });
|
|
68
|
-
}
|
|
69
|
-
// answers and exports not compatible with "noMockTask" mode
|
|
70
|
-
if (noMockTask) {
|
|
71
|
-
if (this._answers || Object.keys(this._exports).length) {
|
|
72
|
-
throw new Error('setAnswers() and registerMockExport() is not compatible with "noMockTask" mode');
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
// register mock task lib
|
|
76
|
-
else {
|
|
77
|
-
var tlm = require('azure-pipelines-task-lib/mock-task');
|
|
78
|
-
if (this._answers) {
|
|
79
|
-
tlm.setAnswers(this._answers);
|
|
80
|
-
}
|
|
81
|
-
Object.keys(this._exports)
|
|
82
|
-
.forEach(function (key) {
|
|
83
|
-
tlm[key] = _this._exports[key];
|
|
84
|
-
});
|
|
85
|
-
mockery.registerMock('azure-pipelines-task-lib/task', tlm);
|
|
86
|
-
}
|
|
87
|
-
// run it
|
|
88
|
-
require(this._taskPath);
|
|
89
|
-
};
|
|
90
|
-
return TaskMockRunner;
|
|
91
|
-
}());
|
|
92
|
-
exports.TaskMockRunner = TaskMockRunner;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskMockRunner = void 0;
|
|
4
|
+
var mockery = require("mockery");
|
|
5
|
+
var im = require("./internal");
|
|
6
|
+
var TaskMockRunner = /** @class */ (function () {
|
|
7
|
+
function TaskMockRunner(taskPath) {
|
|
8
|
+
this._exports = {};
|
|
9
|
+
this._moduleCount = 0;
|
|
10
|
+
this._taskPath = taskPath;
|
|
11
|
+
}
|
|
12
|
+
TaskMockRunner.prototype.setInput = function (name, val) {
|
|
13
|
+
var key = im._getVariableKey(name);
|
|
14
|
+
process.env['INPUT_' + key] = val;
|
|
15
|
+
};
|
|
16
|
+
TaskMockRunner.prototype.setVariableName = function (name, val, isSecret) {
|
|
17
|
+
var key = im._getVariableKey(name);
|
|
18
|
+
if (isSecret) {
|
|
19
|
+
process.env['SECRET_' + key] = val;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
process.env['VSTS_TASKVARIABLE_' + key] = val;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Register answers for the mock "azure-pipelines-task-lib/task" instance.
|
|
27
|
+
*
|
|
28
|
+
* @param answers Answers to be returned when the task lib functions are called.
|
|
29
|
+
*/
|
|
30
|
+
TaskMockRunner.prototype.setAnswers = function (answers) {
|
|
31
|
+
this._answers = answers;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Register a mock module. When require() is called for the module name,
|
|
35
|
+
* the mock implementation will be returned instead.
|
|
36
|
+
*
|
|
37
|
+
* @param modName Module name to override.
|
|
38
|
+
* @param val Mock implementation of the module.
|
|
39
|
+
* @returns void
|
|
40
|
+
*/
|
|
41
|
+
TaskMockRunner.prototype.registerMock = function (modName, mod) {
|
|
42
|
+
this._moduleCount++;
|
|
43
|
+
mockery.registerMock(modName, mod);
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Registers an override for a specific function on the mock "azure-pipelines-task-lib/task" instance.
|
|
47
|
+
* This can be used in conjunction with setAnswers(), for cases where additional runtime
|
|
48
|
+
* control is needed for a specific function.
|
|
49
|
+
*
|
|
50
|
+
* @param key Function or field to override.
|
|
51
|
+
* @param val Function or field value.
|
|
52
|
+
* @returns void
|
|
53
|
+
*/
|
|
54
|
+
TaskMockRunner.prototype.registerMockExport = function (key, val) {
|
|
55
|
+
this._exports[key] = val;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Runs a task script.
|
|
59
|
+
*
|
|
60
|
+
* @param noMockTask Indicates whether to mock "azure-pipelines-task-lib/task". Default is to mock.
|
|
61
|
+
* @returns void
|
|
62
|
+
*/
|
|
63
|
+
TaskMockRunner.prototype.run = function (noMockTask) {
|
|
64
|
+
var _this = this;
|
|
65
|
+
// determine whether to enable mockery
|
|
66
|
+
if (!noMockTask || this._moduleCount) {
|
|
67
|
+
mockery.enable({ warnOnUnregistered: false });
|
|
68
|
+
}
|
|
69
|
+
// answers and exports not compatible with "noMockTask" mode
|
|
70
|
+
if (noMockTask) {
|
|
71
|
+
if (this._answers || Object.keys(this._exports).length) {
|
|
72
|
+
throw new Error('setAnswers() and registerMockExport() is not compatible with "noMockTask" mode');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// register mock task lib
|
|
76
|
+
else {
|
|
77
|
+
var tlm = require('azure-pipelines-task-lib/mock-task');
|
|
78
|
+
if (this._answers) {
|
|
79
|
+
tlm.setAnswers(this._answers);
|
|
80
|
+
}
|
|
81
|
+
Object.keys(this._exports)
|
|
82
|
+
.forEach(function (key) {
|
|
83
|
+
tlm[key] = _this._exports[key];
|
|
84
|
+
});
|
|
85
|
+
mockery.registerMock('azure-pipelines-task-lib/task', tlm);
|
|
86
|
+
}
|
|
87
|
+
// run it
|
|
88
|
+
require(this._taskPath);
|
|
89
|
+
};
|
|
90
|
+
return TaskMockRunner;
|
|
91
|
+
}());
|
|
92
|
+
exports.TaskMockRunner = TaskMockRunner;
|