azure-pipelines-task-lib 4.6.0 → 4.7.0
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/Strings/resources.resjson/en-US/resources.resjson +2 -1
- package/lib-mocker.d.ts +17 -0
- package/lib-mocker.js +199 -0
- package/lib.json +2 -1
- package/mock-answer.d.ts +3 -0
- package/mock-run.js +5 -5
- package/mock-task.d.ts +1 -0
- package/mock-task.js +5 -1
- package/package.json +2 -4
- package/task.d.ts +5 -0
- package/task.js +18 -1
|
@@ -31,5 +31,6 @@
|
|
|
31
31
|
"loc.messages.LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
|
|
32
32
|
"loc.messages.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.",
|
|
33
33
|
"loc.messages.LIB_PlatformNotSupported": "Platform not supported: %s",
|
|
34
|
-
"loc.messages.LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s"
|
|
34
|
+
"loc.messages.LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s",
|
|
35
|
+
"loc.messages.LIB_UndefinedNodeVersion": "Node version is undefined."
|
|
35
36
|
}
|
package/lib-mocker.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface MockOptions {
|
|
2
|
+
useCleanCache?: boolean;
|
|
3
|
+
warnOnReplace?: boolean;
|
|
4
|
+
warnOnUnregistered?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare function enable(opts: MockOptions): void;
|
|
7
|
+
export declare function disable(): void;
|
|
8
|
+
export declare function resetCache(): void;
|
|
9
|
+
export declare function warnOnReplace(enable: boolean): void;
|
|
10
|
+
export declare function warnOnUnregistered(enable: boolean): void;
|
|
11
|
+
export declare function registerMock(mod: string, mock: any): void;
|
|
12
|
+
export declare function deregisterMock(mod: string): void;
|
|
13
|
+
export declare function deregisterAll(): void;
|
|
14
|
+
export declare function registerAllowable(mod: string): void;
|
|
15
|
+
export declare function registerAllowables(mods: string[]): void;
|
|
16
|
+
export declare function deregisterAllowable(mod: string): void;
|
|
17
|
+
export declare function deregisterAllowables(mods: any): void;
|
package/lib-mocker.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deregisterAllowables = exports.deregisterAllowable = exports.registerAllowables = exports.registerAllowable = exports.deregisterAll = exports.deregisterMock = exports.registerMock = exports.warnOnUnregistered = exports.warnOnReplace = exports.resetCache = exports.disable = exports.enable = void 0;
|
|
4
|
+
var m = require('module');
|
|
5
|
+
;
|
|
6
|
+
var registeredMocks = {};
|
|
7
|
+
var registeredAllowables = new Set();
|
|
8
|
+
var originalLoader = null;
|
|
9
|
+
var originalCache = {};
|
|
10
|
+
var options = {};
|
|
11
|
+
var defaultOptions = {
|
|
12
|
+
useCleanCache: false,
|
|
13
|
+
warnOnReplace: true,
|
|
14
|
+
warnOnUnregistered: true
|
|
15
|
+
};
|
|
16
|
+
function _getEffectiveOptions(opts) {
|
|
17
|
+
var options = {};
|
|
18
|
+
Object.keys(defaultOptions).forEach(function (key) {
|
|
19
|
+
if (opts && opts.hasOwnProperty(key)) {
|
|
20
|
+
options[key] = opts[key];
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
options[key] = defaultOptions[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
return options;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* Loader function that used when hooking is enabled.
|
|
30
|
+
* if the requested module is registered as a mock, return the mock.
|
|
31
|
+
* otherwise, invoke the original loader + put warning in the output.
|
|
32
|
+
*/
|
|
33
|
+
function _hookedLoader(request, parent, isMain) {
|
|
34
|
+
if (!originalLoader) {
|
|
35
|
+
throw new Error("Loader has not been hooked");
|
|
36
|
+
}
|
|
37
|
+
if (registeredMocks.hasOwnProperty(request)) {
|
|
38
|
+
return registeredMocks[request];
|
|
39
|
+
}
|
|
40
|
+
if (!registeredAllowables.has(request) && options.warnOnUnregistered) {
|
|
41
|
+
console.warn("WARNING: loading non-allowed module: " + request);
|
|
42
|
+
}
|
|
43
|
+
return originalLoader(request, parent, isMain);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Remove references to modules in the cache from
|
|
47
|
+
* their parents' children.
|
|
48
|
+
*/
|
|
49
|
+
function _removeParentReferences() {
|
|
50
|
+
Object.keys(m._cache).forEach(function (k) {
|
|
51
|
+
var _a;
|
|
52
|
+
if (k.indexOf('\.node') === -1) {
|
|
53
|
+
// don't touch native modules, because they're special
|
|
54
|
+
var mod = m._cache[k];
|
|
55
|
+
var idx = (_a = mod === null || mod === void 0 ? void 0 : mod.parent) === null || _a === void 0 ? void 0 : _a.children.indexOf(mod);
|
|
56
|
+
if (idx > -1) {
|
|
57
|
+
mod.parent.children.splice(idx, 1);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/*
|
|
63
|
+
* Starting in node 0.12 node won't reload native modules
|
|
64
|
+
* The reason is that native modules can register themselves to be loaded automatically
|
|
65
|
+
* This will re-populate the cache with the native modules that have not been mocked
|
|
66
|
+
*/
|
|
67
|
+
function _repopulateNative() {
|
|
68
|
+
Object.keys(originalCache).forEach(function (k) {
|
|
69
|
+
if (k.indexOf('\.node') > -1 && !m._cache[k]) {
|
|
70
|
+
m._cache[k] = originalCache[k];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/*
|
|
75
|
+
* Enable function, hooking the Node loader with options.
|
|
76
|
+
*/
|
|
77
|
+
function enable(opts) {
|
|
78
|
+
if (originalLoader) {
|
|
79
|
+
// Already hooked
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
options = _getEffectiveOptions(opts);
|
|
83
|
+
if (options.useCleanCache) {
|
|
84
|
+
originalCache = m._cache;
|
|
85
|
+
m._cache = {};
|
|
86
|
+
_repopulateNative();
|
|
87
|
+
}
|
|
88
|
+
originalLoader = m._load;
|
|
89
|
+
m._load = _hookedLoader;
|
|
90
|
+
}
|
|
91
|
+
exports.enable = enable;
|
|
92
|
+
/*
|
|
93
|
+
* Disables mock loading, reverting to normal 'require' behaviour.
|
|
94
|
+
*/
|
|
95
|
+
function disable() {
|
|
96
|
+
if (!originalLoader)
|
|
97
|
+
return;
|
|
98
|
+
if (options.useCleanCache) {
|
|
99
|
+
Object.keys(m._cache).forEach(function (k) {
|
|
100
|
+
if (k.indexOf('\.node') > -1 && !originalCache[k]) {
|
|
101
|
+
originalCache[k] = m._cache[k];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
_removeParentReferences();
|
|
105
|
+
m._cache = originalCache;
|
|
106
|
+
originalCache = {};
|
|
107
|
+
}
|
|
108
|
+
m._load = originalLoader;
|
|
109
|
+
originalLoader = null;
|
|
110
|
+
}
|
|
111
|
+
exports.disable = disable;
|
|
112
|
+
/*
|
|
113
|
+
* If the clean cache option is in effect, reset the module cache to an empty
|
|
114
|
+
* state. Calling this function when the clean cache option is not in effect
|
|
115
|
+
* will have no ill effects, but will do nothing.
|
|
116
|
+
*/
|
|
117
|
+
function resetCache() {
|
|
118
|
+
if (options.useCleanCache && originalCache) {
|
|
119
|
+
_removeParentReferences();
|
|
120
|
+
m._cache = {};
|
|
121
|
+
_repopulateNative();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.resetCache = resetCache;
|
|
125
|
+
/*
|
|
126
|
+
* Enable or disable warnings to the console when previously registered mocks are replaced.
|
|
127
|
+
*/
|
|
128
|
+
function warnOnReplace(enable) {
|
|
129
|
+
options.warnOnReplace = enable;
|
|
130
|
+
}
|
|
131
|
+
exports.warnOnReplace = warnOnReplace;
|
|
132
|
+
/*
|
|
133
|
+
* Enable or disable warnings to the console when modules are loaded that have
|
|
134
|
+
* not been registered as a mock.
|
|
135
|
+
*/
|
|
136
|
+
function warnOnUnregistered(enable) {
|
|
137
|
+
options.warnOnUnregistered = enable;
|
|
138
|
+
}
|
|
139
|
+
exports.warnOnUnregistered = warnOnUnregistered;
|
|
140
|
+
/*
|
|
141
|
+
* Register a mock object for the specified module.
|
|
142
|
+
*/
|
|
143
|
+
function registerMock(mod, mock) {
|
|
144
|
+
if (options.warnOnReplace && registeredMocks.hasOwnProperty(mod)) {
|
|
145
|
+
console.warn("WARNING: Replacing existing mock for module: " + mod);
|
|
146
|
+
}
|
|
147
|
+
registeredMocks[mod] = mock;
|
|
148
|
+
}
|
|
149
|
+
exports.registerMock = registerMock;
|
|
150
|
+
/*
|
|
151
|
+
* Deregister a mock object for the specified module.
|
|
152
|
+
*/
|
|
153
|
+
function deregisterMock(mod) {
|
|
154
|
+
if (registeredMocks.hasOwnProperty(mod)) {
|
|
155
|
+
delete registeredMocks[mod];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.deregisterMock = deregisterMock;
|
|
159
|
+
/*
|
|
160
|
+
* Deregister all mocks.
|
|
161
|
+
*/
|
|
162
|
+
function deregisterAll() {
|
|
163
|
+
registeredMocks = {};
|
|
164
|
+
registeredAllowables = new Set();
|
|
165
|
+
}
|
|
166
|
+
exports.deregisterAll = deregisterAll;
|
|
167
|
+
/*
|
|
168
|
+
Register a module as 'allowed'.
|
|
169
|
+
This will allow the module to be loaded without mock otherwise a warning would be thrown.
|
|
170
|
+
*/
|
|
171
|
+
function registerAllowable(mod) {
|
|
172
|
+
registeredAllowables.add(mod);
|
|
173
|
+
}
|
|
174
|
+
exports.registerAllowable = registerAllowable;
|
|
175
|
+
/*
|
|
176
|
+
* Register an array of 'allowed' modules.
|
|
177
|
+
*/
|
|
178
|
+
function registerAllowables(mods) {
|
|
179
|
+
mods.forEach(function (mod) { return registerAllowable(mod); });
|
|
180
|
+
}
|
|
181
|
+
exports.registerAllowables = registerAllowables;
|
|
182
|
+
/*
|
|
183
|
+
* Deregister a module as 'allowed'.
|
|
184
|
+
*/
|
|
185
|
+
function deregisterAllowable(mod) {
|
|
186
|
+
if (registeredAllowables.hasOwnProperty(mod)) {
|
|
187
|
+
registeredAllowables.delete(mod);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.deregisterAllowable = deregisterAllowable;
|
|
191
|
+
/*
|
|
192
|
+
* Deregister an array of modules as 'allowed'.
|
|
193
|
+
*/
|
|
194
|
+
function deregisterAllowables(mods) {
|
|
195
|
+
mods.forEach(function (mod) {
|
|
196
|
+
deregisterAllowable(mod);
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
exports.deregisterAllowables = deregisterAllowables;
|
package/lib.json
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"LIB_UseFirstGlobMatch": "Multiple workspace matches. using first.",
|
|
33
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
34
|
"LIB_PlatformNotSupported": "Platform not supported: %s",
|
|
35
|
-
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s"
|
|
35
|
+
"LIB_CopyFileFailed": "Error while copying the file. Attempts left: %s",
|
|
36
|
+
"LIB_UndefinedNodeVersion": "Node version is undefined."
|
|
36
37
|
}
|
|
37
38
|
}
|
package/mock-answer.d.ts
CHANGED
package/mock-run.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TaskMockRunner = void 0;
|
|
4
|
-
var mockery = require("mockery");
|
|
5
4
|
var im = require("./internal");
|
|
5
|
+
var mocker = require("./lib-mocker");
|
|
6
6
|
var TaskMockRunner = /** @class */ (function () {
|
|
7
7
|
function TaskMockRunner(taskPath) {
|
|
8
8
|
this._exports = {};
|
|
@@ -40,7 +40,7 @@ var TaskMockRunner = /** @class */ (function () {
|
|
|
40
40
|
*/
|
|
41
41
|
TaskMockRunner.prototype.registerMock = function (modName, mod) {
|
|
42
42
|
this._moduleCount++;
|
|
43
|
-
|
|
43
|
+
mocker.registerMock(modName, mod);
|
|
44
44
|
};
|
|
45
45
|
/**
|
|
46
46
|
* Registers an override for a specific function on the mock "azure-pipelines-task-lib/task" instance.
|
|
@@ -62,9 +62,9 @@ var TaskMockRunner = /** @class */ (function () {
|
|
|
62
62
|
*/
|
|
63
63
|
TaskMockRunner.prototype.run = function (noMockTask) {
|
|
64
64
|
var _this = this;
|
|
65
|
-
// determine whether to enable
|
|
65
|
+
// determine whether to enable mocker
|
|
66
66
|
if (!noMockTask || this._moduleCount) {
|
|
67
|
-
|
|
67
|
+
mocker.enable({ warnOnUnregistered: false });
|
|
68
68
|
}
|
|
69
69
|
// answers and exports not compatible with "noMockTask" mode
|
|
70
70
|
if (noMockTask) {
|
|
@@ -82,7 +82,7 @@ var TaskMockRunner = /** @class */ (function () {
|
|
|
82
82
|
.forEach(function (key) {
|
|
83
83
|
tlm[key] = _this._exports[key];
|
|
84
84
|
});
|
|
85
|
-
|
|
85
|
+
mocker.registerMock('azure-pipelines-task-lib/task', tlm);
|
|
86
86
|
}
|
|
87
87
|
// run it
|
|
88
88
|
require(this._taskPath);
|
package/mock-task.d.ts
CHANGED
|
@@ -58,6 +58,7 @@ export interface FsOptions {
|
|
|
58
58
|
export declare function writeFile(file: string, data: string | Buffer, options?: string | FsOptions): void;
|
|
59
59
|
export declare function osType(): string;
|
|
60
60
|
export declare function getPlatform(): task.Platform;
|
|
61
|
+
export declare function getNodeMajorVersion(): Number;
|
|
61
62
|
export declare function getAgentMode(): task.AgentHostedMode;
|
|
62
63
|
export declare function cwd(): string;
|
|
63
64
|
export declare function cd(path: string): void;
|
package/mock-task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.legacyFindFiles = exports.findMatch = exports.tool = exports.execSync = exports.execAsync = exports.exec = exports.mv = exports.rmRF = exports.find = exports.retry = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.checkPath = exports.popd = exports.pushd = exports.cd = exports.cwd = exports.getAgentMode = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.FsStats = exports.loc = exports.setResourcePath = exports.setAnswers = void 0;
|
|
3
|
+
exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.legacyFindFiles = exports.findMatch = exports.tool = exports.execSync = exports.execAsync = exports.exec = exports.mv = exports.rmRF = exports.find = exports.retry = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.checkPath = exports.popd = exports.pushd = exports.cd = exports.cwd = exports.getAgentMode = exports.getNodeMajorVersion = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.FsStats = exports.loc = exports.setResourcePath = exports.setAnswers = void 0;
|
|
4
4
|
var path = require("path");
|
|
5
5
|
var task = require("./task");
|
|
6
6
|
var tcm = require("./taskcommand");
|
|
@@ -189,6 +189,10 @@ function getPlatform() {
|
|
|
189
189
|
return mock.getResponse('getPlatform', 'getPlatform', module.exports.debug);
|
|
190
190
|
}
|
|
191
191
|
exports.getPlatform = getPlatform;
|
|
192
|
+
function getNodeMajorVersion() {
|
|
193
|
+
return mock.getResponse('getNodeMajorVersion', 'getNodeMajorVersion', module.exports.debug);
|
|
194
|
+
}
|
|
195
|
+
exports.getNodeMajorVersion = getNodeMajorVersion;
|
|
192
196
|
function getAgentMode() {
|
|
193
197
|
return mock.getResponse('getAgentMode', 'getAgentMode', module.exports.debug);
|
|
194
198
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "azure-pipelines-task-lib",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "Azure Pipelines Task SDK",
|
|
5
5
|
"main": "./task.js",
|
|
6
6
|
"typings": "./task.d.ts",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
"adm-zip": "^0.5.10",
|
|
31
31
|
"deasync": "^0.1.28",
|
|
32
32
|
"minimatch": "3.0.5",
|
|
33
|
-
"mockery": "^2.1.0",
|
|
34
33
|
"nodejs-file-downloader": "^4.11.1",
|
|
35
34
|
"q": "^1.5.1",
|
|
36
35
|
"semver": "^5.1.0",
|
|
@@ -40,8 +39,7 @@
|
|
|
40
39
|
"devDependencies": {
|
|
41
40
|
"@types/minimatch": "3.0.3",
|
|
42
41
|
"@types/mocha": "^9.1.1",
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/node": "^10.17.0",
|
|
42
|
+
"@types/node": "^16.11.39",
|
|
45
43
|
"@types/q": "^1.5.4",
|
|
46
44
|
"@types/semver": "^7.3.4",
|
|
47
45
|
"@types/shelljs": "^0.8.8",
|
package/task.d.ts
CHANGED
|
@@ -325,6 +325,11 @@ export declare function osType(): string;
|
|
|
325
325
|
* @throws {Error} Platform is not supported by our agent
|
|
326
326
|
*/
|
|
327
327
|
export declare function getPlatform(): Platform;
|
|
328
|
+
/**
|
|
329
|
+
* Resolves major version of Node.js engine used by the agent.
|
|
330
|
+
* @returns {Number} Node's major version.
|
|
331
|
+
*/
|
|
332
|
+
export declare function getNodeMajorVersion(): Number;
|
|
328
333
|
/**
|
|
329
334
|
* Return hosted type of Agent
|
|
330
335
|
* @returns {AgentHostedMode}
|
package/task.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.execAsync = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getAgentMode = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
|
|
3
|
+
exports.updateReleaseName = exports.addBuildTag = exports.updateBuildNumber = exports.uploadBuildLog = exports.associateArtifact = exports.uploadArtifact = exports.logIssue = exports.logDetail = exports.setProgress = exports.setEndpoint = exports.addAttachment = exports.uploadSummary = exports.prependPath = exports.uploadFile = exports.CodeCoverageEnabler = exports.CodeCoveragePublisher = exports.TestPublisher = exports.getHttpCertConfiguration = exports.getHttpProxyConfiguration = exports.findMatch = exports.filter = exports.match = exports.tool = exports.execSync = exports.exec = exports.execAsync = exports.rmRF = exports.legacyFindFiles = exports.find = exports.retry = exports.mv = exports.cp = exports.ls = exports.which = exports.resolve = exports.mkdirP = exports.popd = exports.pushd = exports.cd = exports.checkPath = exports.cwd = exports.getAgentMode = exports.getNodeMajorVersion = exports.getPlatform = exports.osType = exports.writeFile = exports.exist = exports.stats = exports.debug = exports.error = exports.warning = exports.command = exports.setTaskVariable = exports.getTaskVariable = exports.getSecureFileTicket = exports.getSecureFileName = exports.getEndpointAuthorization = exports.getEndpointAuthorizationParameterRequired = exports.getEndpointAuthorizationParameter = exports.getEndpointAuthorizationSchemeRequired = exports.getEndpointAuthorizationScheme = exports.getEndpointDataParameterRequired = exports.getEndpointDataParameter = exports.getEndpointUrlRequired = exports.getEndpointUrl = exports.getPathInputRequired = exports.getPathInput = exports.filePathSupplied = exports.getDelimitedInput = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
|
|
4
4
|
var shell = require("shelljs");
|
|
5
5
|
var childProcess = require("child_process");
|
|
6
6
|
var fs = require("fs");
|
|
@@ -616,6 +616,23 @@ function getPlatform() {
|
|
|
616
616
|
}
|
|
617
617
|
}
|
|
618
618
|
exports.getPlatform = getPlatform;
|
|
619
|
+
/**
|
|
620
|
+
* Resolves major version of Node.js engine used by the agent.
|
|
621
|
+
* @returns {Number} Node's major version.
|
|
622
|
+
*/
|
|
623
|
+
function getNodeMajorVersion() {
|
|
624
|
+
var _a;
|
|
625
|
+
var version = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node;
|
|
626
|
+
if (!version) {
|
|
627
|
+
throw new Error(exports.loc('LIB_UndefinedNodeVersion'));
|
|
628
|
+
}
|
|
629
|
+
var parts = version.split('.').map(Number);
|
|
630
|
+
if (parts.length < 1) {
|
|
631
|
+
return NaN;
|
|
632
|
+
}
|
|
633
|
+
return parts[0];
|
|
634
|
+
}
|
|
635
|
+
exports.getNodeMajorVersion = getNodeMajorVersion;
|
|
619
636
|
/**
|
|
620
637
|
* Return hosted type of Agent
|
|
621
638
|
* @returns {AgentHostedMode}
|