azure-pipelines-task-lib 5.0.0-preview.0 → 5.0.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/de-DE/resources.resjson +35 -34
- package/Strings/resources.resjson/en-US/resources.resjson +24 -20
- package/Strings/resources.resjson/es-ES/resources.resjson +35 -34
- package/Strings/resources.resjson/fr-FR/resources.resjson +35 -34
- package/Strings/resources.resjson/it-IT/resources.resjson +2 -1
- package/Strings/resources.resjson/ja-JP/resources.resjson +35 -34
- package/Strings/resources.resjson/ko-KR/resources.resjson +2 -1
- package/Strings/resources.resjson/ru-RU/resources.resjson +2 -1
- package/Strings/resources.resjson/zh-CN/resources.resjson +2 -1
- package/Strings/resources.resjson/zh-TW/resources.resjson +2 -1
- package/ThirdPartyNotice.txt +5 -3
- package/internal.d.ts +13 -2
- package/internal.js +73 -20
- package/lib.json +26 -22
- package/mock-answer.d.ts +4 -1
- package/mock-answer.js +2 -2
- package/mock-task.d.ts +3 -0
- package/mock-task.js +20 -2
- package/mock-test.d.ts +3 -2
- package/mock-test.js +296 -166
- package/mock-toolrunner.d.ts +7 -0
- package/mock-toolrunner.js +95 -1
- package/package.json +4 -3
- package/task.d.ts +121 -33
- package/task.js +565 -262
- package/toolrunner.d.ts +15 -1
- package/toolrunner.js +360 -43
package/mock-test.js
CHANGED
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.MockTestRunner = void 0;
|
|
4
40
|
var cp = require("child_process");
|
|
5
41
|
var fs = require("fs");
|
|
6
|
-
var ncp = require("child_process");
|
|
7
42
|
var os = require("os");
|
|
8
43
|
var path = require("path");
|
|
9
44
|
var cmdm = require("./taskcommand");
|
|
10
45
|
var shelljs = require("shelljs");
|
|
11
|
-
var
|
|
46
|
+
var Downloader = require("nodejs-file-downloader");
|
|
12
47
|
var COMMAND_TAG = '[command]';
|
|
13
48
|
var COMMAND_LENGTH = COMMAND_TAG.length;
|
|
14
49
|
var downloadDirectory = path.join(process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE, 'azure-pipelines-task-lib', '_download');
|
|
@@ -24,10 +59,42 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
24
59
|
this.succeeded = false;
|
|
25
60
|
this.errorIssues = [];
|
|
26
61
|
this.warningIssues = [];
|
|
62
|
+
if (testPath === undefined)
|
|
63
|
+
return;
|
|
27
64
|
this._taskJsonPath = taskJsonPath || '';
|
|
28
65
|
this._testPath = testPath;
|
|
29
|
-
this.nodePath = this.getNodePath();
|
|
30
66
|
}
|
|
67
|
+
MockTestRunner.prototype.LoadAsync = function (testPath, taskJsonPath) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
69
|
+
var _this = this;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
72
|
+
var _a;
|
|
73
|
+
return __generator(this, function (_b) {
|
|
74
|
+
switch (_b.label) {
|
|
75
|
+
case 0:
|
|
76
|
+
if (this.nodePath != '') {
|
|
77
|
+
resolve(this);
|
|
78
|
+
return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
if (testPath) {
|
|
81
|
+
this._testPath = testPath;
|
|
82
|
+
}
|
|
83
|
+
if (taskJsonPath) {
|
|
84
|
+
this._taskJsonPath = taskJsonPath;
|
|
85
|
+
}
|
|
86
|
+
_a = this;
|
|
87
|
+
return [4 /*yield*/, this.getNodePath()];
|
|
88
|
+
case 1:
|
|
89
|
+
_a.nodePath = _b.sent();
|
|
90
|
+
resolve(this);
|
|
91
|
+
return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); })];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
31
98
|
Object.defineProperty(MockTestRunner.prototype, "failed", {
|
|
32
99
|
get: function () {
|
|
33
100
|
return !this.succeeded;
|
|
@@ -50,103 +117,125 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
50
117
|
MockTestRunner.prototype.stdErrContained = function (message) {
|
|
51
118
|
return this.stderr.indexOf(message) > 0;
|
|
52
119
|
};
|
|
53
|
-
MockTestRunner.prototype.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
120
|
+
MockTestRunner.prototype.runAsync = function (nodeVersion) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
122
|
+
var nodePath, spawn, lines, traceFile;
|
|
123
|
+
var _this = this;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
this.cmdlines = {};
|
|
128
|
+
this.invokedToolCount = 0;
|
|
129
|
+
this.succeeded = true;
|
|
130
|
+
this.errorIssues = [];
|
|
131
|
+
this.warningIssues = [];
|
|
132
|
+
nodePath = this.nodePath;
|
|
133
|
+
if (!nodeVersion) return [3 /*break*/, 2];
|
|
134
|
+
return [4 /*yield*/, this.getNodePath(nodeVersion)];
|
|
135
|
+
case 1:
|
|
136
|
+
nodePath = _a.sent();
|
|
137
|
+
return [3 /*break*/, 4];
|
|
138
|
+
case 2:
|
|
139
|
+
if (!!nodePath) return [3 /*break*/, 4];
|
|
140
|
+
return [4 /*yield*/, this.getNodePath()];
|
|
141
|
+
case 3:
|
|
142
|
+
nodePath = _a.sent();
|
|
143
|
+
this.nodePath = nodePath;
|
|
144
|
+
_a.label = 4;
|
|
145
|
+
case 4:
|
|
146
|
+
spawn = cp.spawnSync(nodePath, [this._testPath]);
|
|
147
|
+
// Clean environment
|
|
148
|
+
Object.keys(process.env)
|
|
149
|
+
.filter(function (key) { return (key.substr(0, 'INPUT_'.length) === 'INPUT_' ||
|
|
150
|
+
key.substr(0, 'SECRET_'.length) === 'SECRET_' ||
|
|
151
|
+
key.substr(0, 'VSTS_TASKVARIABLE_'.length) === 'VSTS_TASKVARIABLE_'); })
|
|
152
|
+
.forEach(function (key) { return delete process.env[key]; });
|
|
153
|
+
if (spawn.error) {
|
|
154
|
+
console.error('Running test failed');
|
|
155
|
+
console.error(spawn.error.message);
|
|
156
|
+
return [2 /*return*/];
|
|
157
|
+
}
|
|
158
|
+
this.stdout = spawn.stdout.toString();
|
|
159
|
+
this.stderr = spawn.stderr.toString();
|
|
160
|
+
if (process.env['TASK_TEST_TRACE']) {
|
|
161
|
+
console.log('');
|
|
162
|
+
}
|
|
163
|
+
lines = this.stdout.replace(/\r\n/g, '\n').split('\n');
|
|
164
|
+
traceFile = this._testPath + '.log';
|
|
165
|
+
lines.forEach(function (line) {
|
|
166
|
+
var ci = line.indexOf('##vso[');
|
|
167
|
+
var cmd;
|
|
168
|
+
var cmi = line.indexOf(COMMAND_TAG);
|
|
169
|
+
if (ci >= 0) {
|
|
170
|
+
cmd = cmdm.commandFromString(line.substring(ci));
|
|
171
|
+
if (cmd.command === 'task.complete' && cmd.properties['result'] === 'Failed') {
|
|
172
|
+
_this.succeeded = false;
|
|
173
|
+
}
|
|
174
|
+
if (cmd.command === 'task.issue' && cmd.properties['type'] === 'error') {
|
|
175
|
+
_this.errorIssues.push(cmd.message.trim());
|
|
176
|
+
}
|
|
177
|
+
if (cmd.command === 'task.issue' && cmd.properties['type'] === 'warning') {
|
|
178
|
+
_this.warningIssues.push(cmd.message.trim());
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else if (cmi == 0 && line.length > COMMAND_LENGTH) {
|
|
182
|
+
var cmdline = line.substr(COMMAND_LENGTH).trim();
|
|
183
|
+
_this.cmdlines[cmdline] = true;
|
|
184
|
+
_this.invokedToolCount++;
|
|
185
|
+
}
|
|
186
|
+
if (process.env['TASK_TEST_TRACE']) {
|
|
187
|
+
fs.appendFileSync(traceFile, line + os.EOL);
|
|
188
|
+
if (line && !cmd) {
|
|
189
|
+
console.log(line);
|
|
190
|
+
}
|
|
191
|
+
// don't print task.debug commands to console - too noisy.
|
|
192
|
+
// otherwise omit command details - can interfere during CI.
|
|
193
|
+
else if (cmd && cmd.command != 'task.debug') {
|
|
194
|
+
console.log("".concat(cmd.command, " details omitted"));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
if (this.stderr && process.env['TASK_TEST_TRACE']) {
|
|
199
|
+
console.log('STDERR: ' + this.stderr);
|
|
200
|
+
fs.appendFileSync(traceFile, 'STDERR: ' + this.stderr + os.EOL);
|
|
201
|
+
}
|
|
202
|
+
if (process.env['TASK_TEST_TRACE']) {
|
|
203
|
+
console.log('TRACE FILE: ' + traceFile);
|
|
204
|
+
}
|
|
205
|
+
return [2 /*return*/];
|
|
91
206
|
}
|
|
92
|
-
|
|
93
|
-
_this.errorIssues.push(cmd.message.trim());
|
|
94
|
-
}
|
|
95
|
-
if (cmd.command === 'task.issue' && cmd.properties['type'] === 'warning') {
|
|
96
|
-
_this.warningIssues.push(cmd.message.trim());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
else if (cmi == 0 && line.length > COMMAND_LENGTH) {
|
|
100
|
-
var cmdline = line.substr(COMMAND_LENGTH).trim();
|
|
101
|
-
_this.cmdlines[cmdline] = true;
|
|
102
|
-
_this.invokedToolCount++;
|
|
103
|
-
}
|
|
104
|
-
if (process.env['TASK_TEST_TRACE']) {
|
|
105
|
-
fs.appendFileSync(traceFile, line + os.EOL);
|
|
106
|
-
if (line && !cmd) {
|
|
107
|
-
console.log(line);
|
|
108
|
-
}
|
|
109
|
-
// don't print task.debug commands to console - too noisy.
|
|
110
|
-
// otherwise omit command details - can interfere during CI.
|
|
111
|
-
else if (cmd && cmd.command != 'task.debug') {
|
|
112
|
-
console.log(cmd.command + " details omitted");
|
|
113
|
-
}
|
|
114
|
-
}
|
|
207
|
+
});
|
|
115
208
|
});
|
|
116
|
-
if (this.stderr && process.env['TASK_TEST_TRACE']) {
|
|
117
|
-
console.log('STDERR: ' + this.stderr);
|
|
118
|
-
fs.appendFileSync(traceFile, 'STDERR: ' + this.stderr + os.EOL);
|
|
119
|
-
}
|
|
120
|
-
if (process.env['TASK_TEST_TRACE']) {
|
|
121
|
-
console.log('TRACE FILE: ' + traceFile);
|
|
122
|
-
}
|
|
123
209
|
};
|
|
124
210
|
// Returns a path to node.exe with the correct version for this task (based on if its node10 or node)
|
|
125
211
|
MockTestRunner.prototype.getNodePath = function (nodeVersion) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
212
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
213
|
+
var version, versions, downloadVersion, downloadDestination, pathToExe, result;
|
|
214
|
+
return __generator(this, function (_a) {
|
|
215
|
+
switch (_a.label) {
|
|
216
|
+
case 0:
|
|
217
|
+
version = nodeVersion || this.getNodeVersion();
|
|
218
|
+
versions = {
|
|
219
|
+
20: 'v20.13.1',
|
|
220
|
+
16: 'v16.20.2',
|
|
221
|
+
10: 'v10.24.1',
|
|
222
|
+
6: 'v6.17.1',
|
|
223
|
+
};
|
|
224
|
+
downloadVersion = versions[version];
|
|
225
|
+
if (!downloadVersion) {
|
|
226
|
+
throw new Error('Invalid node version, must be 6, 10, 16 or 20 (received ' + version + ')');
|
|
227
|
+
}
|
|
228
|
+
downloadDestination = path.join(downloadDirectory, 'node' + version);
|
|
229
|
+
pathToExe = this.getPathToNodeExe(downloadVersion, downloadDestination);
|
|
230
|
+
if (!pathToExe) return [3 /*break*/, 1];
|
|
231
|
+
return [2 /*return*/, pathToExe];
|
|
232
|
+
case 1: return [4 /*yield*/, this.downloadNode(downloadVersion, downloadDestination)];
|
|
233
|
+
case 2:
|
|
234
|
+
result = _a.sent();
|
|
235
|
+
return [2 /*return*/, result];
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
});
|
|
150
239
|
};
|
|
151
240
|
// Determines the correct version of node to use based on the contents of the task's task.json. Defaults to Node 16.
|
|
152
241
|
MockTestRunner.prototype.getNodeVersion = function () {
|
|
@@ -157,29 +246,27 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
157
246
|
}
|
|
158
247
|
var taskJsonContents = fs.readFileSync(taskJsonPath, { encoding: 'utf-8' });
|
|
159
248
|
var taskJson = JSON.parse(taskJsonContents);
|
|
160
|
-
var
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
else if (keys[i].toLowerCase() == 'node') {
|
|
175
|
-
nodeVersionFound = true;
|
|
249
|
+
var nodeVersion = 0;
|
|
250
|
+
var executors = ['execution', 'prejobexecution', 'postjobexecution'];
|
|
251
|
+
for (var _i = 0, executors_1 = executors; _i < executors_1.length; _i++) {
|
|
252
|
+
var executor = executors_1[_i];
|
|
253
|
+
if (!taskJson[executor])
|
|
254
|
+
continue;
|
|
255
|
+
for (var _a = 0, _b = Object.keys(taskJson[executor]); _a < _b.length; _a++) {
|
|
256
|
+
var key = _b[_a];
|
|
257
|
+
var currExecutor = key.toLocaleLowerCase();
|
|
258
|
+
if (!currExecutor.startsWith('node'))
|
|
259
|
+
continue;
|
|
260
|
+
var version = currExecutor.replace('node', '');
|
|
261
|
+
var intVersion = parseInt(version) || 6; // node handler is node v6 by default
|
|
262
|
+
nodeVersion = Math.max(intVersion, nodeVersion);
|
|
176
263
|
}
|
|
177
264
|
}
|
|
178
|
-
if (
|
|
265
|
+
if (nodeVersion === 0) {
|
|
179
266
|
console.warn('Unable to determine execution type from task.json, defaulting to use Node 16');
|
|
180
267
|
return 16;
|
|
181
268
|
}
|
|
182
|
-
return
|
|
269
|
+
return nodeVersion;
|
|
183
270
|
};
|
|
184
271
|
// Returns the path to the task.json for the task being tested. Returns null if unable to find it.
|
|
185
272
|
// Searches by moving up the directory structure from the initial starting point and checking at each level.
|
|
@@ -201,65 +288,108 @@ var MockTestRunner = /** @class */ (function () {
|
|
|
201
288
|
};
|
|
202
289
|
// Downloads the specified node version to the download destination. Returns a path to node.exe
|
|
203
290
|
MockTestRunner.prototype.downloadNode = function (nodeVersion, downloadDestination) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
291
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
+
var nodeUrl, downloadPath, _a, marker;
|
|
293
|
+
return __generator(this, function (_b) {
|
|
294
|
+
switch (_b.label) {
|
|
295
|
+
case 0:
|
|
296
|
+
shelljs.rm('-rf', downloadDestination);
|
|
297
|
+
nodeUrl = process.env['TASK_NODE_URL'] || 'https://nodejs.org/dist';
|
|
298
|
+
nodeUrl = nodeUrl.replace(/\/$/, ''); // ensure there is no trailing slash on the base URL
|
|
299
|
+
downloadPath = '';
|
|
300
|
+
_a = this.getPlatform();
|
|
301
|
+
switch (_a) {
|
|
302
|
+
case 'darwin': return [3 /*break*/, 1];
|
|
303
|
+
case 'linux': return [3 /*break*/, 3];
|
|
304
|
+
case 'win32': return [3 /*break*/, 5];
|
|
305
|
+
}
|
|
306
|
+
return [3 /*break*/, 8];
|
|
307
|
+
case 1: return [4 /*yield*/, this.downloadTarGz(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-darwin-x64.tar.gz', downloadDestination)];
|
|
308
|
+
case 2:
|
|
309
|
+
_b.sent();
|
|
310
|
+
downloadPath = path.join(downloadDestination, 'node-' + nodeVersion + '-darwin-x64', 'bin', 'node');
|
|
311
|
+
return [3 /*break*/, 8];
|
|
312
|
+
case 3: return [4 /*yield*/, this.downloadTarGz(nodeUrl + '/' + nodeVersion + '/node-' + nodeVersion + '-linux-x64.tar.gz', downloadDestination)];
|
|
313
|
+
case 4:
|
|
314
|
+
_b.sent();
|
|
315
|
+
downloadPath = path.join(downloadDestination, 'node-' + nodeVersion + '-linux-x64', 'bin', 'node');
|
|
316
|
+
return [3 /*break*/, 8];
|
|
317
|
+
case 5: return [4 /*yield*/, this.downloadFile(nodeUrl + '/' + nodeVersion + '/win-x64/node.exe', downloadDestination, 'node.exe')];
|
|
318
|
+
case 6:
|
|
319
|
+
_b.sent();
|
|
320
|
+
return [4 /*yield*/, this.downloadFile(nodeUrl + '/' + nodeVersion + '/win-x64/node.lib', downloadDestination, 'node.lib')];
|
|
321
|
+
case 7:
|
|
322
|
+
_b.sent();
|
|
323
|
+
downloadPath = path.join(downloadDestination, 'node.exe');
|
|
324
|
+
_b.label = 8;
|
|
325
|
+
case 8:
|
|
326
|
+
marker = downloadDestination + '.completed';
|
|
327
|
+
fs.writeFileSync(marker, '');
|
|
328
|
+
return [2 /*return*/, downloadPath];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
});
|
|
226
332
|
};
|
|
227
333
|
// Downloads file to the downloadDestination, making any necessary folders along the way.
|
|
228
334
|
MockTestRunner.prototype.downloadFile = function (url, downloadDestination, fileName) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
335
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
+
var downloader;
|
|
337
|
+
return __generator(this, function (_a) {
|
|
338
|
+
switch (_a.label) {
|
|
339
|
+
case 0:
|
|
340
|
+
if (!url) {
|
|
341
|
+
throw new Error('Parameter "url" must be set.');
|
|
342
|
+
}
|
|
343
|
+
if (!downloadDestination) {
|
|
344
|
+
throw new Error('Parameter "downloadDestination" must be set.');
|
|
345
|
+
}
|
|
346
|
+
console.log('Downloading file:', url);
|
|
347
|
+
shelljs.mkdir('-p', downloadDestination);
|
|
348
|
+
downloader = new Downloader({
|
|
349
|
+
url: url,
|
|
350
|
+
directory: downloadDestination,
|
|
351
|
+
fileName: fileName
|
|
352
|
+
});
|
|
353
|
+
return [4 /*yield*/, downloader.download()];
|
|
354
|
+
case 1:
|
|
355
|
+
_a.sent();
|
|
356
|
+
return [2 /*return*/];
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
});
|
|
240
360
|
};
|
|
241
361
|
// Downloads tarGz to the download destination, making any necessary folders along the way.
|
|
242
362
|
MockTestRunner.prototype.downloadTarGz = function (url, downloadDestination) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
363
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
364
|
+
var tarGzName, originalCwd;
|
|
365
|
+
return __generator(this, function (_a) {
|
|
366
|
+
switch (_a.label) {
|
|
367
|
+
case 0:
|
|
368
|
+
if (!url) {
|
|
369
|
+
throw new Error('Parameter "url" must be set.');
|
|
370
|
+
}
|
|
371
|
+
if (!downloadDestination) {
|
|
372
|
+
throw new Error('Parameter "downloadDestination" must be set.');
|
|
373
|
+
}
|
|
374
|
+
tarGzName = 'node.tar.gz';
|
|
375
|
+
return [4 /*yield*/, this.downloadFile(url, downloadDestination, tarGzName)];
|
|
376
|
+
case 1:
|
|
377
|
+
_a.sent();
|
|
378
|
+
originalCwd = process.cwd();
|
|
379
|
+
process.chdir(downloadDestination);
|
|
380
|
+
try {
|
|
381
|
+
cp.execSync("tar -xzf \"".concat(path.join(downloadDestination, tarGzName), "\""));
|
|
382
|
+
}
|
|
383
|
+
catch (_b) {
|
|
384
|
+
throw new Error('Failed to unzip node tar.gz from ' + url);
|
|
385
|
+
}
|
|
386
|
+
finally {
|
|
387
|
+
process.chdir(originalCwd);
|
|
388
|
+
}
|
|
389
|
+
return [2 /*return*/];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
263
393
|
};
|
|
264
394
|
// Checks if node is installed at downloadDestination. If it is, returns a path to node.exe, otherwise returns null.
|
|
265
395
|
MockTestRunner.prototype.getPathToNodeExe = function (nodeVersion, downloadDestination) {
|
package/mock-toolrunner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import Q = require('q');
|
|
3
4
|
import events = require('events');
|
|
4
5
|
import ma = require('./mock-answer');
|
|
@@ -36,6 +37,12 @@ export declare class ToolRunner extends events.EventEmitter {
|
|
|
36
37
|
line(val: string): ToolRunner;
|
|
37
38
|
pipeExecOutputToTool(tool: ToolRunner): ToolRunner;
|
|
38
39
|
private ignoreTempPath;
|
|
40
|
+
execAsync(options?: IExecOptions): Promise<number>;
|
|
41
|
+
/**
|
|
42
|
+
* Exec - use for long running tools where you need to stream live output as it runs
|
|
43
|
+
* @deprecated use `execAsync` instead
|
|
44
|
+
* @returns a promise with return code.
|
|
45
|
+
*/
|
|
39
46
|
exec(options?: IExecOptions): Q.Promise<number>;
|
|
40
47
|
execSync(options?: IExecSyncOptions): IExecSyncResult;
|
|
41
48
|
}
|