azure-pipelines-task-lib 5.0.1-preview.0 → 5.2.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/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.js +29 -34
- package/mock-toolrunner.d.ts +7 -0
- package/mock-toolrunner.js +95 -1
- package/package.json +2 -2
- package/task.d.ts +121 -33
- package/task.js +631 -287
- package/toolrunner.d.ts +15 -1
- package/toolrunner.js +360 -43
package/task.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
12
|
+
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.getPipelineFeature = exports.getBoolFeatureFlag = exports.getBoolInput = exports.getInputRequired = exports.getInput = exports.setSecret = exports.setVariable = exports.getVariables = exports.assertAgent = exports.getVariable = exports.loc = exports.setResourcePath = exports.setSanitizedResult = exports.setResult = exports.setErrStream = exports.setStdStream = exports.AgentHostedMode = exports.Platform = exports.IssueSource = exports.FieldType = exports.ArtifactType = exports.IssueType = exports.TaskState = exports.TaskResult = void 0;
|
|
13
|
+
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 = void 0;
|
|
5
14
|
var childProcess = require("child_process");
|
|
6
15
|
var fs = require("fs");
|
|
7
16
|
var path = require("path");
|
|
@@ -45,6 +54,7 @@ var FieldType;
|
|
|
45
54
|
FieldType[FieldType["DataParameter"] = 1] = "DataParameter";
|
|
46
55
|
FieldType[FieldType["Url"] = 2] = "Url";
|
|
47
56
|
})(FieldType = exports.FieldType || (exports.FieldType = {}));
|
|
57
|
+
exports.IssueSource = im.IssueSource;
|
|
48
58
|
/** Platforms supported by our build agent */
|
|
49
59
|
var Platform;
|
|
50
60
|
(function (Platform) {
|
|
@@ -64,28 +74,47 @@ var AgentHostedMode;
|
|
|
64
74
|
exports.setStdStream = im._setStdStream;
|
|
65
75
|
exports.setErrStream = im._setErrStream;
|
|
66
76
|
function setResult(result, message, done) {
|
|
67
|
-
exports.debug('task result: ' + TaskResult[result]);
|
|
77
|
+
(0, exports.debug)('task result: ' + TaskResult[result]);
|
|
68
78
|
// add an error issue
|
|
69
79
|
if (result == TaskResult.Failed && message) {
|
|
70
|
-
exports.error(message);
|
|
80
|
+
(0, exports.error)(message, exports.IssueSource.TaskInternal);
|
|
71
81
|
}
|
|
72
82
|
else if (result == TaskResult.SucceededWithIssues && message) {
|
|
73
|
-
exports.warning(message);
|
|
83
|
+
(0, exports.warning)(message, exports.IssueSource.TaskInternal);
|
|
74
84
|
}
|
|
75
85
|
// task.complete
|
|
76
86
|
var properties = { 'result': TaskResult[result] };
|
|
77
87
|
if (done) {
|
|
78
88
|
properties['done'] = 'true';
|
|
79
89
|
}
|
|
80
|
-
exports.command('task.complete', properties, message);
|
|
90
|
+
(0, exports.command)('task.complete', properties, message);
|
|
81
91
|
}
|
|
82
92
|
exports.setResult = setResult;
|
|
93
|
+
/**
|
|
94
|
+
* Sets the result of the task with sanitized message.
|
|
95
|
+
*
|
|
96
|
+
* @param result TaskResult enum of Succeeded, SucceededWithIssues, Failed, Cancelled or Skipped.
|
|
97
|
+
* @param message A message which will be logged as an error issue if the result is Failed. Message will be truncated
|
|
98
|
+
* before first occurence of wellknown sensitive keyword.
|
|
99
|
+
* @param done Optional. Instructs the agent the task is done. This is helpful when child processes
|
|
100
|
+
* may still be running and prevent node from fully exiting. This argument is supported
|
|
101
|
+
* from agent version 2.142.0 or higher (otherwise will no-op).
|
|
102
|
+
* @returns void
|
|
103
|
+
*/
|
|
104
|
+
function setSanitizedResult(result, message, done) {
|
|
105
|
+
var pattern = /password|key|secret|bearer|authorization|token|pat/i;
|
|
106
|
+
var sanitizedMessage = im._truncateBeforeSensitiveKeyword(message, pattern);
|
|
107
|
+
setResult(result, sanitizedMessage, done);
|
|
108
|
+
}
|
|
109
|
+
exports.setSanitizedResult = setSanitizedResult;
|
|
83
110
|
//
|
|
84
111
|
// Catching all exceptions
|
|
85
112
|
//
|
|
86
113
|
process.on('uncaughtException', function (err) {
|
|
87
|
-
|
|
88
|
-
|
|
114
|
+
if (!im.isSigPipeError(err)) {
|
|
115
|
+
setResult(TaskResult.Failed, (0, exports.loc)('LIB_UnhandledEx', err.message));
|
|
116
|
+
(0, exports.error)(String(err.stack), im.IssueSource.TaskInternal);
|
|
117
|
+
}
|
|
89
118
|
});
|
|
90
119
|
//
|
|
91
120
|
// Catching unhandled rejections from promises and rethrowing them as exceptions
|
|
@@ -119,9 +148,10 @@ function assertAgent(minimum) {
|
|
|
119
148
|
if (semver.lt(minimum, '2.104.1')) {
|
|
120
149
|
throw new Error('assertAgent() requires the parameter to be 2.104.1 or higher');
|
|
121
150
|
}
|
|
122
|
-
var agent = exports.getVariable('Agent.Version');
|
|
151
|
+
var agent = (0, exports.getVariable)('Agent.Version');
|
|
152
|
+
(0, exports.debug)('Detected Agent.Version=' + (agent ? agent : 'undefined'));
|
|
123
153
|
if (agent && semver.lt(agent, minimum)) {
|
|
124
|
-
throw new Error("Agent version "
|
|
154
|
+
throw new Error("Agent version ".concat(minimum, " or higher is required. Detected Agent version: ").concat(agent));
|
|
125
155
|
}
|
|
126
156
|
}
|
|
127
157
|
exports.assertAgent = assertAgent;
|
|
@@ -142,7 +172,7 @@ function getVariables() {
|
|
|
142
172
|
return Object.keys(im._knownVariableMap)
|
|
143
173
|
.map(function (key) {
|
|
144
174
|
var info = im._knownVariableMap[key];
|
|
145
|
-
return { name: info.name, value: exports.getVariable(info.name), secret: info.secret };
|
|
175
|
+
return { name: info.name, value: (0, exports.getVariable)(info.name), secret: info.secret };
|
|
146
176
|
});
|
|
147
177
|
}
|
|
148
178
|
exports.getVariables = getVariables;
|
|
@@ -165,10 +195,10 @@ function setVariable(name, val, secret, isOutput) {
|
|
|
165
195
|
}
|
|
166
196
|
// store the value
|
|
167
197
|
var varValue = val || '';
|
|
168
|
-
exports.debug('set ' + name + '=' + (secret && varValue ? '********' : varValue));
|
|
198
|
+
(0, exports.debug)('set ' + name + '=' + (secret && varValue ? '********' : varValue));
|
|
169
199
|
if (secret) {
|
|
170
|
-
if (varValue && varValue.match(/\r|\n/) &&
|
|
171
|
-
throw new Error(exports.loc('LIB_MultilineSecret'));
|
|
200
|
+
if (varValue && varValue.match(/\r|\n/) && "".concat(process.env['SYSTEM_UNSAFEALLOWMULTILINESECRET']).toUpperCase() != 'TRUE') {
|
|
201
|
+
throw new Error((0, exports.loc)('LIB_MultilineSecret'));
|
|
172
202
|
}
|
|
173
203
|
im._vault.storeSecret('SECRET_' + key, varValue);
|
|
174
204
|
delete process.env[key];
|
|
@@ -179,7 +209,7 @@ function setVariable(name, val, secret, isOutput) {
|
|
|
179
209
|
// store the metadata
|
|
180
210
|
im._knownVariableMap[key] = { name: name, secret: secret };
|
|
181
211
|
// write the setvariable command
|
|
182
|
-
exports.command('task.setvariable', { 'variable': name || '', isOutput: (isOutput || false).toString(), 'issecret': (secret || false).toString() }, varValue);
|
|
212
|
+
(0, exports.command)('task.setvariable', { 'variable': name || '', isOutput: (isOutput || false).toString(), 'issecret': (secret || false).toString() }, varValue);
|
|
183
213
|
}
|
|
184
214
|
exports.setVariable = setVariable;
|
|
185
215
|
/**
|
|
@@ -189,10 +219,10 @@ exports.setVariable = setVariable;
|
|
|
189
219
|
*/
|
|
190
220
|
function setSecret(val) {
|
|
191
221
|
if (val) {
|
|
192
|
-
if (val.match(/\r|\n/) &&
|
|
193
|
-
throw new Error(exports.loc('LIB_MultilineSecret'));
|
|
222
|
+
if (val.match(/\r|\n/) && "".concat(process.env['SYSTEM_UNSAFEALLOWMULTILINESECRET']).toUpperCase() !== 'TRUE') {
|
|
223
|
+
throw new Error((0, exports.loc)('LIB_MultilineSecret'));
|
|
194
224
|
}
|
|
195
|
-
exports.command('task.setsecret', {}, val);
|
|
225
|
+
(0, exports.command)('task.setsecret', {}, val);
|
|
196
226
|
}
|
|
197
227
|
}
|
|
198
228
|
exports.setSecret = setSecret;
|
|
@@ -207,9 +237,9 @@ exports.setSecret = setSecret;
|
|
|
207
237
|
function getInput(name, required) {
|
|
208
238
|
var inval = im._vault.retrieveSecret('INPUT_' + im._getVariableKey(name));
|
|
209
239
|
if (required && !inval) {
|
|
210
|
-
throw new Error(exports.loc('LIB_InputRequired', name));
|
|
240
|
+
throw new Error((0, exports.loc)('LIB_InputRequired', name));
|
|
211
241
|
}
|
|
212
|
-
exports.debug(name + '=' + inval);
|
|
242
|
+
(0, exports.debug)(name + '=' + inval);
|
|
213
243
|
return inval;
|
|
214
244
|
}
|
|
215
245
|
exports.getInput = getInput;
|
|
@@ -239,22 +269,41 @@ function getBoolInput(name, required) {
|
|
|
239
269
|
exports.getBoolInput = getBoolInput;
|
|
240
270
|
/**
|
|
241
271
|
* Gets the value of an feature flag and converts to a bool.
|
|
242
|
-
*
|
|
272
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
243
273
|
* @param name name of the feature flag to get.
|
|
244
274
|
* @param defaultValue default value of the feature flag in case it's not found in env. (optional. Default value = false)
|
|
245
275
|
* @returns boolean
|
|
276
|
+
* @deprecated Don't use this for new development. Use getPipelineFeature instead.
|
|
246
277
|
*/
|
|
247
278
|
function getBoolFeatureFlag(ffName, defaultValue) {
|
|
248
279
|
if (defaultValue === void 0) { defaultValue = false; }
|
|
249
280
|
var ffValue = process.env[ffName];
|
|
250
281
|
if (!ffValue) {
|
|
251
|
-
exports.debug("Feature flag "
|
|
282
|
+
(0, exports.debug)("Feature flag ".concat(ffName, " not found. Returning ").concat(defaultValue, " as default."));
|
|
252
283
|
return defaultValue;
|
|
253
284
|
}
|
|
254
|
-
exports.debug("Feature flag "
|
|
285
|
+
(0, exports.debug)("Feature flag ".concat(ffName, " = ").concat(ffValue));
|
|
255
286
|
return ffValue.toLowerCase() === "true";
|
|
256
287
|
}
|
|
257
288
|
exports.getBoolFeatureFlag = getBoolFeatureFlag;
|
|
289
|
+
/**
|
|
290
|
+
* Gets the value of an task feature and converts to a bool.
|
|
291
|
+
* @IMPORTANT This method is only for internal Microsoft development. Do not use it for external tasks.
|
|
292
|
+
* @param name name of the feature to get.
|
|
293
|
+
* @returns boolean
|
|
294
|
+
*/
|
|
295
|
+
function getPipelineFeature(featureName) {
|
|
296
|
+
var variableName = im._getVariableKey("DistributedTask.Tasks.".concat(featureName));
|
|
297
|
+
var featureValue = process.env[variableName];
|
|
298
|
+
if (!featureValue) {
|
|
299
|
+
(0, exports.debug)("Feature '".concat(featureName, "' not found. Returning false as default."));
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
var boolValue = featureValue.toLowerCase() === "true";
|
|
303
|
+
(0, exports.debug)("Feature '".concat(featureName, "' = '").concat(featureValue, "'. Processed as '").concat(boolValue, "'."));
|
|
304
|
+
return boolValue;
|
|
305
|
+
}
|
|
306
|
+
exports.getPipelineFeature = getPipelineFeature;
|
|
258
307
|
/**
|
|
259
308
|
* Gets the value of an input and splits the value using a delimiter (space, comma, etc).
|
|
260
309
|
* Empty values are removed. This function is useful for splitting an input containing a simple
|
|
@@ -293,9 +342,9 @@ exports.getDelimitedInput = getDelimitedInput;
|
|
|
293
342
|
function filePathSupplied(name) {
|
|
294
343
|
// normalize paths
|
|
295
344
|
var pathValue = this.resolve(this.getPathInput(name) || '');
|
|
296
|
-
var repoRoot = this.resolve(exports.getVariable('build.sourcesDirectory') || exports.getVariable('system.defaultWorkingDirectory') || '');
|
|
345
|
+
var repoRoot = this.resolve((0, exports.getVariable)('build.sourcesDirectory') || (0, exports.getVariable)('system.defaultWorkingDirectory') || '');
|
|
297
346
|
var supplied = pathValue !== repoRoot;
|
|
298
|
-
exports.debug(name + 'path supplied :' + supplied);
|
|
347
|
+
(0, exports.debug)(name + 'path supplied :' + supplied);
|
|
299
348
|
return supplied;
|
|
300
349
|
}
|
|
301
350
|
exports.filePathSupplied = filePathSupplied;
|
|
@@ -314,7 +363,7 @@ function getPathInput(name, required, check) {
|
|
|
314
363
|
var inval = getInput(name, required);
|
|
315
364
|
if (inval) {
|
|
316
365
|
if (check) {
|
|
317
|
-
exports.checkPath(inval, name);
|
|
366
|
+
(0, exports.checkPath)(inval, name);
|
|
318
367
|
}
|
|
319
368
|
}
|
|
320
369
|
return inval;
|
|
@@ -348,9 +397,9 @@ exports.getPathInputRequired = getPathInputRequired;
|
|
|
348
397
|
function getEndpointUrl(id, optional) {
|
|
349
398
|
var urlval = process.env['ENDPOINT_URL_' + id];
|
|
350
399
|
if (!optional && !urlval) {
|
|
351
|
-
throw new Error(exports.loc('LIB_EndpointNotExist', id));
|
|
400
|
+
throw new Error((0, exports.loc)('LIB_EndpointNotExist', id));
|
|
352
401
|
}
|
|
353
|
-
exports.debug(id + '=' + urlval);
|
|
402
|
+
(0, exports.debug)(id + '=' + urlval);
|
|
354
403
|
return urlval;
|
|
355
404
|
}
|
|
356
405
|
exports.getEndpointUrl = getEndpointUrl;
|
|
@@ -377,9 +426,9 @@ exports.getEndpointUrlRequired = getEndpointUrlRequired;
|
|
|
377
426
|
function getEndpointDataParameter(id, key, optional) {
|
|
378
427
|
var dataParamVal = process.env['ENDPOINT_DATA_' + id + '_' + key.toUpperCase()];
|
|
379
428
|
if (!optional && !dataParamVal) {
|
|
380
|
-
throw new Error(exports.loc('LIB_EndpointDataNotExist', id, key));
|
|
429
|
+
throw new Error((0, exports.loc)('LIB_EndpointDataNotExist', id, key));
|
|
381
430
|
}
|
|
382
|
-
exports.debug(id + ' data ' + key + ' = ' + dataParamVal);
|
|
431
|
+
(0, exports.debug)(id + ' data ' + key + ' = ' + dataParamVal);
|
|
383
432
|
return dataParamVal;
|
|
384
433
|
}
|
|
385
434
|
exports.getEndpointDataParameter = getEndpointDataParameter;
|
|
@@ -406,9 +455,9 @@ exports.getEndpointDataParameterRequired = getEndpointDataParameterRequired;
|
|
|
406
455
|
function getEndpointAuthorizationScheme(id, optional) {
|
|
407
456
|
var authScheme = im._vault.retrieveSecret('ENDPOINT_AUTH_SCHEME_' + id);
|
|
408
457
|
if (!optional && !authScheme) {
|
|
409
|
-
throw new Error(exports.loc('LIB_EndpointAuthNotExist', id));
|
|
458
|
+
throw new Error((0, exports.loc)('LIB_EndpointAuthNotExist', id));
|
|
410
459
|
}
|
|
411
|
-
exports.debug(id + ' auth scheme = ' + authScheme);
|
|
460
|
+
(0, exports.debug)(id + ' auth scheme = ' + authScheme);
|
|
412
461
|
return authScheme;
|
|
413
462
|
}
|
|
414
463
|
exports.getEndpointAuthorizationScheme = getEndpointAuthorizationScheme;
|
|
@@ -435,9 +484,9 @@ exports.getEndpointAuthorizationSchemeRequired = getEndpointAuthorizationSchemeR
|
|
|
435
484
|
function getEndpointAuthorizationParameter(id, key, optional) {
|
|
436
485
|
var authParam = im._vault.retrieveSecret('ENDPOINT_AUTH_PARAMETER_' + id + '_' + key.toUpperCase());
|
|
437
486
|
if (!optional && !authParam) {
|
|
438
|
-
throw new Error(exports.loc('LIB_EndpointAuthNotExist', id));
|
|
487
|
+
throw new Error((0, exports.loc)('LIB_EndpointAuthNotExist', id));
|
|
439
488
|
}
|
|
440
|
-
exports.debug(id + ' auth param ' + key + ' = ' + authParam);
|
|
489
|
+
(0, exports.debug)(id + ' auth param ' + key + ' = ' + authParam);
|
|
441
490
|
return authParam;
|
|
442
491
|
}
|
|
443
492
|
exports.getEndpointAuthorizationParameter = getEndpointAuthorizationParameter;
|
|
@@ -464,9 +513,9 @@ exports.getEndpointAuthorizationParameterRequired = getEndpointAuthorizationPara
|
|
|
464
513
|
function getEndpointAuthorization(id, optional) {
|
|
465
514
|
var aval = im._vault.retrieveSecret('ENDPOINT_AUTH_' + id);
|
|
466
515
|
if (!optional && !aval) {
|
|
467
|
-
setResult(TaskResult.Failed, exports.loc('LIB_EndpointAuthNotExist', id));
|
|
516
|
+
setResult(TaskResult.Failed, (0, exports.loc)('LIB_EndpointAuthNotExist', id));
|
|
468
517
|
}
|
|
469
|
-
exports.debug(id + ' exists ' + (!!aval));
|
|
518
|
+
(0, exports.debug)(id + ' exists ' + (!!aval));
|
|
470
519
|
var auth;
|
|
471
520
|
try {
|
|
472
521
|
if (aval) {
|
|
@@ -474,7 +523,7 @@ function getEndpointAuthorization(id, optional) {
|
|
|
474
523
|
}
|
|
475
524
|
}
|
|
476
525
|
catch (err) {
|
|
477
|
-
throw new Error(exports.loc('LIB_InvalidEndpointAuth', aval));
|
|
526
|
+
throw new Error((0, exports.loc)('LIB_InvalidEndpointAuth', aval));
|
|
478
527
|
}
|
|
479
528
|
return auth;
|
|
480
529
|
}
|
|
@@ -490,7 +539,7 @@ exports.getEndpointAuthorization = getEndpointAuthorization;
|
|
|
490
539
|
*/
|
|
491
540
|
function getSecureFileName(id) {
|
|
492
541
|
var name = process.env['SECUREFILE_NAME_' + id];
|
|
493
|
-
exports.debug('secure file name for id ' + id + ' = ' + name);
|
|
542
|
+
(0, exports.debug)('secure file name for id ' + id + ' = ' + name);
|
|
494
543
|
return name;
|
|
495
544
|
}
|
|
496
545
|
exports.getSecureFileName = getSecureFileName;
|
|
@@ -502,7 +551,7 @@ exports.getSecureFileName = getSecureFileName;
|
|
|
502
551
|
*/
|
|
503
552
|
function getSecureFileTicket(id) {
|
|
504
553
|
var ticket = im._vault.retrieveSecret('SECUREFILE_TICKET_' + id);
|
|
505
|
-
exports.debug('secure file ticket for id ' + id + ' = ' + ticket);
|
|
554
|
+
(0, exports.debug)('secure file ticket for id ' + id + ' = ' + ticket);
|
|
506
555
|
return ticket;
|
|
507
556
|
}
|
|
508
557
|
exports.getSecureFileTicket = getSecureFileTicket;
|
|
@@ -522,7 +571,7 @@ function getTaskVariable(name) {
|
|
|
522
571
|
if (inval) {
|
|
523
572
|
inval = inval.trim();
|
|
524
573
|
}
|
|
525
|
-
exports.debug('task variable: ' + name + '=' + inval);
|
|
574
|
+
(0, exports.debug)('task variable: ' + name + '=' + inval);
|
|
526
575
|
return inval;
|
|
527
576
|
}
|
|
528
577
|
exports.getTaskVariable = getTaskVariable;
|
|
@@ -541,11 +590,11 @@ function setTaskVariable(name, val, secret) {
|
|
|
541
590
|
var key = im._getVariableKey(name);
|
|
542
591
|
// store the value
|
|
543
592
|
var varValue = val || '';
|
|
544
|
-
exports.debug('set task variable: ' + name + '=' + (secret && varValue ? '********' : varValue));
|
|
593
|
+
(0, exports.debug)('set task variable: ' + name + '=' + (secret && varValue ? '********' : varValue));
|
|
545
594
|
im._vault.storeSecret('VSTS_TASKVARIABLE_' + key, varValue);
|
|
546
595
|
delete process.env[key];
|
|
547
596
|
// write the command
|
|
548
|
-
exports.command('task.settaskvariable', { 'variable': name || '', 'issecret': (secret || false).toString() }, varValue);
|
|
597
|
+
(0, exports.command)('task.settaskvariable', { 'variable': name || '', 'issecret': (secret || false).toString() }, varValue);
|
|
549
598
|
}
|
|
550
599
|
exports.setTaskVariable = setTaskVariable;
|
|
551
600
|
//-----------------------------------------------------
|
|
@@ -558,17 +607,6 @@ exports.debug = im._debug;
|
|
|
558
607
|
//-----------------------------------------------------
|
|
559
608
|
// Disk Functions
|
|
560
609
|
//-----------------------------------------------------
|
|
561
|
-
function _checkShell(cmd, continueOnError) {
|
|
562
|
-
var se = shell.error();
|
|
563
|
-
if (se) {
|
|
564
|
-
exports.debug(cmd + ' failed');
|
|
565
|
-
var errMsg = exports.loc('LIB_OperationFailed', cmd, se);
|
|
566
|
-
exports.debug(errMsg);
|
|
567
|
-
if (!continueOnError) {
|
|
568
|
-
throw new Error(errMsg);
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
610
|
/**
|
|
573
611
|
* Get's stat on a path.
|
|
574
612
|
* Useful for checking whether a file or directory. Also getting created, modified and accessed time.
|
|
@@ -612,16 +650,33 @@ function getPlatform() {
|
|
|
612
650
|
case 'win32': return Platform.Windows;
|
|
613
651
|
case 'darwin': return Platform.MacOS;
|
|
614
652
|
case 'linux': return Platform.Linux;
|
|
615
|
-
default: throw Error(exports.loc('LIB_PlatformNotSupported', process.platform));
|
|
653
|
+
default: throw Error((0, exports.loc)('LIB_PlatformNotSupported', process.platform));
|
|
616
654
|
}
|
|
617
655
|
}
|
|
618
656
|
exports.getPlatform = getPlatform;
|
|
657
|
+
/**
|
|
658
|
+
* Resolves major version of Node.js engine used by the agent.
|
|
659
|
+
* @returns {Number} Node's major version.
|
|
660
|
+
*/
|
|
661
|
+
function getNodeMajorVersion() {
|
|
662
|
+
var _a;
|
|
663
|
+
var version = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node;
|
|
664
|
+
if (!version) {
|
|
665
|
+
throw new Error((0, exports.loc)('LIB_UndefinedNodeVersion'));
|
|
666
|
+
}
|
|
667
|
+
var parts = version.split('.').map(Number);
|
|
668
|
+
if (parts.length < 1) {
|
|
669
|
+
return NaN;
|
|
670
|
+
}
|
|
671
|
+
return parts[0];
|
|
672
|
+
}
|
|
673
|
+
exports.getNodeMajorVersion = getNodeMajorVersion;
|
|
619
674
|
/**
|
|
620
675
|
* Return hosted type of Agent
|
|
621
676
|
* @returns {AgentHostedMode}
|
|
622
677
|
*/
|
|
623
678
|
function getAgentMode() {
|
|
624
|
-
var agentCloudId = exports.getVariable('Agent.CloudId');
|
|
679
|
+
var agentCloudId = (0, exports.getVariable)('Agent.CloudId');
|
|
625
680
|
if (agentCloudId === undefined)
|
|
626
681
|
return AgentHostedMode.Unknown;
|
|
627
682
|
if (agentCloudId)
|
|
@@ -643,60 +698,137 @@ exports.checkPath = im._checkPath;
|
|
|
643
698
|
/**
|
|
644
699
|
* Change working directory.
|
|
645
700
|
*
|
|
646
|
-
* @param
|
|
647
|
-
* @returns
|
|
701
|
+
* @param {string} path - New working directory path
|
|
702
|
+
* @returns {void}
|
|
648
703
|
*/
|
|
649
704
|
function cd(path) {
|
|
650
|
-
if (path) {
|
|
651
|
-
|
|
652
|
-
|
|
705
|
+
if (path === '-') {
|
|
706
|
+
if (!process.env.OLDPWD) {
|
|
707
|
+
throw new Error((0, exports.loc)('LIB_NotFoundPreviousDirectory'));
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
path = process.env.OLDPWD;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (path === '~') {
|
|
714
|
+
path = os.homedir();
|
|
715
|
+
}
|
|
716
|
+
if (!fs.existsSync(path)) {
|
|
717
|
+
throw new Error((0, exports.loc)('LIB_PathNotFound', 'cd', path));
|
|
718
|
+
}
|
|
719
|
+
if (!fs.statSync(path).isDirectory()) {
|
|
720
|
+
throw new Error((0, exports.loc)('LIB_PathIsNotADirectory', path));
|
|
721
|
+
}
|
|
722
|
+
try {
|
|
723
|
+
var currentPath = process.cwd();
|
|
724
|
+
process.chdir(path);
|
|
725
|
+
process.env.OLDPWD = currentPath;
|
|
726
|
+
}
|
|
727
|
+
catch (error) {
|
|
728
|
+
(0, exports.debug)((0, exports.loc)('LIB_OperationFailed', 'cd', error));
|
|
653
729
|
}
|
|
654
730
|
}
|
|
655
731
|
exports.cd = cd;
|
|
732
|
+
var dirStack = [];
|
|
733
|
+
function getActualStack() {
|
|
734
|
+
return [process.cwd()].concat(dirStack);
|
|
735
|
+
}
|
|
656
736
|
/**
|
|
657
737
|
* Change working directory and push it on the stack
|
|
658
738
|
*
|
|
659
|
-
* @param
|
|
660
|
-
* @returns
|
|
739
|
+
* @param {string} dir - New working directory path
|
|
740
|
+
* @returns {void}
|
|
661
741
|
*/
|
|
662
|
-
function pushd(
|
|
663
|
-
|
|
664
|
-
|
|
742
|
+
function pushd(dir) {
|
|
743
|
+
if (dir === void 0) { dir = ''; }
|
|
744
|
+
var dirs = getActualStack();
|
|
745
|
+
var maybeIndex = parseInt(dir);
|
|
746
|
+
if (dir === '+0') {
|
|
747
|
+
return dirs;
|
|
748
|
+
}
|
|
749
|
+
else if (dir.length === 0) {
|
|
750
|
+
if (dirs.length > 1) {
|
|
751
|
+
dirs.splice.apply(dirs, __spreadArray([0, 0], dirs.splice(1, 1), false));
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
throw new Error((0, exports.loc)('LIB_DirectoryStackEmpty'));
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
else if (!isNaN(maybeIndex)) {
|
|
758
|
+
if (maybeIndex < dirStack.length + 1) {
|
|
759
|
+
maybeIndex = dir.charAt(0) === '-' ? maybeIndex - 1 : maybeIndex;
|
|
760
|
+
}
|
|
761
|
+
dirs.splice.apply(dirs, __spreadArray([0, dirs.length], dirs.slice(maybeIndex).concat(dirs.slice(0, maybeIndex)), false));
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
dirs.unshift(dir);
|
|
765
|
+
}
|
|
766
|
+
var _path = path.resolve(dirs.shift());
|
|
767
|
+
try {
|
|
768
|
+
cd(_path);
|
|
769
|
+
}
|
|
770
|
+
catch (error) {
|
|
771
|
+
if (!fs.existsSync(_path)) {
|
|
772
|
+
throw new Error((0, exports.loc)('Not found', 'pushd', _path));
|
|
773
|
+
}
|
|
774
|
+
throw error;
|
|
775
|
+
}
|
|
776
|
+
dirStack.splice.apply(dirStack, __spreadArray([0, dirStack.length], dirs, false));
|
|
777
|
+
return getActualStack();
|
|
665
778
|
}
|
|
666
779
|
exports.pushd = pushd;
|
|
667
780
|
/**
|
|
668
781
|
* Change working directory back to previously pushed directory
|
|
669
782
|
*
|
|
670
|
-
* @
|
|
783
|
+
* @param {string} index - Index to remove from the stack
|
|
784
|
+
* @returns {void}
|
|
671
785
|
*/
|
|
672
|
-
function popd() {
|
|
673
|
-
|
|
674
|
-
|
|
786
|
+
function popd(index) {
|
|
787
|
+
if (index === void 0) { index = ''; }
|
|
788
|
+
if (dirStack.length === 0) {
|
|
789
|
+
throw new Error((0, exports.loc)('LIB_DirectoryStackEmpty'));
|
|
790
|
+
}
|
|
791
|
+
var maybeIndex = parseInt(index);
|
|
792
|
+
if (isNaN(maybeIndex)) {
|
|
793
|
+
maybeIndex = 0;
|
|
794
|
+
}
|
|
795
|
+
else if (maybeIndex < dirStack.length + 1) {
|
|
796
|
+
maybeIndex = index.charAt(0) === '-' ? maybeIndex - 1 : maybeIndex;
|
|
797
|
+
}
|
|
798
|
+
if (maybeIndex > 0 || dirStack.length + maybeIndex === 0) {
|
|
799
|
+
maybeIndex = maybeIndex > 0 ? maybeIndex - 1 : maybeIndex;
|
|
800
|
+
dirStack.splice(maybeIndex, 1);
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
var _path = path.resolve(dirStack.shift());
|
|
804
|
+
cd(_path);
|
|
805
|
+
}
|
|
806
|
+
return getActualStack();
|
|
675
807
|
}
|
|
676
808
|
exports.popd = popd;
|
|
677
809
|
/**
|
|
678
|
-
* Make a directory.
|
|
810
|
+
* Make a directory. Creates the full path with folders in between
|
|
679
811
|
* Will throw if it fails
|
|
680
812
|
*
|
|
681
|
-
* @param
|
|
682
|
-
* @returns
|
|
813
|
+
* @param {string} p - Path to create
|
|
814
|
+
* @returns {void}
|
|
683
815
|
*/
|
|
684
816
|
function mkdirP(p) {
|
|
685
817
|
if (!p) {
|
|
686
|
-
throw new Error(exports.loc('LIB_ParameterIsRequired', 'p'));
|
|
818
|
+
throw new Error((0, exports.loc)('LIB_ParameterIsRequired', 'p'));
|
|
687
819
|
}
|
|
688
820
|
// build a stack of directories to create
|
|
689
821
|
var stack = [];
|
|
690
822
|
var testDir = p;
|
|
691
823
|
while (true) {
|
|
692
824
|
// validate the loop is not out of control
|
|
693
|
-
if (stack.length >= (process.env['TASKLIB_TEST_MKDIRP_FAILSAFE'] || 1000)) {
|
|
825
|
+
if (stack.length >= Number(process.env['TASKLIB_TEST_MKDIRP_FAILSAFE'] || 1000)) {
|
|
694
826
|
// let the framework throw
|
|
695
|
-
exports.debug('loop is out of control');
|
|
827
|
+
(0, exports.debug)('loop is out of control');
|
|
696
828
|
fs.mkdirSync(p);
|
|
697
829
|
return;
|
|
698
830
|
}
|
|
699
|
-
exports.debug("testing directory '"
|
|
831
|
+
(0, exports.debug)("testing directory '".concat(testDir, "'"));
|
|
700
832
|
var stats_1 = void 0;
|
|
701
833
|
try {
|
|
702
834
|
stats_1 = fs.statSync(testDir);
|
|
@@ -706,7 +838,7 @@ function mkdirP(p) {
|
|
|
706
838
|
// validate the directory is not the drive root
|
|
707
839
|
var parentDir = path.dirname(testDir);
|
|
708
840
|
if (testDir == parentDir) {
|
|
709
|
-
throw new Error(exports.loc('LIB_MkdirFailedInvalidDriveRoot', p, testDir)); // Unable to create directory '{p}'. Root directory does not exist: '{testDir}'
|
|
841
|
+
throw new Error((0, exports.loc)('LIB_MkdirFailedInvalidDriveRoot', p, testDir)); // Unable to create directory '{p}'. Root directory does not exist: '{testDir}'
|
|
710
842
|
}
|
|
711
843
|
// push the dir and test the parent
|
|
712
844
|
stack.push(testDir);
|
|
@@ -714,14 +846,14 @@ function mkdirP(p) {
|
|
|
714
846
|
continue;
|
|
715
847
|
}
|
|
716
848
|
else if (err.code == 'UNKNOWN') {
|
|
717
|
-
throw new Error(exports.loc('LIB_MkdirFailedInvalidShare', p, testDir)); // Unable to create directory '{p}'. Unable to verify the directory exists: '{testDir}'. 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.
|
|
849
|
+
throw new Error((0, exports.loc)('LIB_MkdirFailedInvalidShare', p, testDir)); // Unable to create directory '{p}'. Unable to verify the directory exists: '{testDir}'. 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.
|
|
718
850
|
}
|
|
719
851
|
else {
|
|
720
852
|
throw err;
|
|
721
853
|
}
|
|
722
854
|
}
|
|
723
855
|
if (!stats_1.isDirectory()) {
|
|
724
|
-
throw new Error(exports.loc('LIB_MkdirFailedFileExists', p, testDir)); // Unable to create directory '{p}'. Conflicting file exists: '{testDir}'
|
|
856
|
+
throw new Error((0, exports.loc)('LIB_MkdirFailedFileExists', p, testDir)); // Unable to create directory '{p}'. Conflicting file exists: '{testDir}'
|
|
725
857
|
}
|
|
726
858
|
// testDir exists
|
|
727
859
|
break;
|
|
@@ -729,12 +861,12 @@ function mkdirP(p) {
|
|
|
729
861
|
// create each directory
|
|
730
862
|
while (stack.length) {
|
|
731
863
|
var dir = stack.pop(); // non-null because `stack.length` was truthy
|
|
732
|
-
exports.debug("mkdir '"
|
|
864
|
+
(0, exports.debug)("mkdir '".concat(dir, "'"));
|
|
733
865
|
try {
|
|
734
866
|
fs.mkdirSync(dir);
|
|
735
867
|
}
|
|
736
868
|
catch (err) {
|
|
737
|
-
throw new Error(exports.loc('LIB_MkdirFailed', p, err.message)); // Unable to create directory '{p}'. {err.message}
|
|
869
|
+
throw new Error((0, exports.loc)('LIB_MkdirFailed', p, err.message)); // Unable to create directory '{p}'. {err.message}
|
|
738
870
|
}
|
|
739
871
|
}
|
|
740
872
|
}
|
|
@@ -752,82 +884,253 @@ function resolve() {
|
|
|
752
884
|
pathSegments[_i] = arguments[_i];
|
|
753
885
|
}
|
|
754
886
|
var absolutePath = path.resolve.apply(this, pathSegments);
|
|
755
|
-
exports.debug('Absolute path for pathSegments: ' + pathSegments + ' = ' + absolutePath);
|
|
887
|
+
(0, exports.debug)('Absolute path for pathSegments: ' + pathSegments + ' = ' + absolutePath);
|
|
756
888
|
return absolutePath;
|
|
757
889
|
}
|
|
758
890
|
exports.resolve = resolve;
|
|
759
891
|
exports.which = im._which;
|
|
760
892
|
/**
|
|
761
|
-
* Returns array of files in the given path, or in current directory if no path provided.
|
|
762
|
-
* @param {
|
|
763
|
-
* @param {
|
|
764
|
-
* @return {string[]}
|
|
893
|
+
* Returns array of files in the given path, or in current directory if no path provided.
|
|
894
|
+
* @param {unknown} optionsOrPaths - Available options: -R (recursive), -A (all files, include files beginning with ., except for . and ..)
|
|
895
|
+
* @param {unknown[]} paths - Paths to search.
|
|
896
|
+
* @return {string[]} - An array of files in the given path(s).
|
|
765
897
|
*/
|
|
766
|
-
function ls(
|
|
767
|
-
|
|
768
|
-
|
|
898
|
+
function ls(optionsOrPaths) {
|
|
899
|
+
var paths = [];
|
|
900
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
901
|
+
paths[_i - 1] = arguments[_i];
|
|
769
902
|
}
|
|
770
|
-
|
|
771
|
-
|
|
903
|
+
var isRecursive = false;
|
|
904
|
+
var includeHidden = false;
|
|
905
|
+
if (typeof optionsOrPaths === 'string' && optionsOrPaths.startsWith('-')) {
|
|
906
|
+
var options = String(optionsOrPaths).toLowerCase();
|
|
907
|
+
isRecursive = options.includes('r');
|
|
908
|
+
includeHidden = options.includes('a');
|
|
909
|
+
}
|
|
910
|
+
// Flatten paths if the paths argument is array
|
|
911
|
+
if (Array.isArray(paths)) {
|
|
912
|
+
paths = paths.flat(Infinity);
|
|
913
|
+
}
|
|
914
|
+
// If the first argument is not options, then it is a path
|
|
915
|
+
if (typeof optionsOrPaths !== 'string' || !optionsOrPaths.startsWith('-')) {
|
|
916
|
+
var pathsFromOptions = [];
|
|
917
|
+
if (Array.isArray(optionsOrPaths)) {
|
|
918
|
+
pathsFromOptions = optionsOrPaths;
|
|
919
|
+
}
|
|
920
|
+
else if (optionsOrPaths && typeof optionsOrPaths === 'string') {
|
|
921
|
+
pathsFromOptions = [optionsOrPaths];
|
|
922
|
+
}
|
|
923
|
+
if (paths === undefined || paths.length === 0) {
|
|
924
|
+
paths = pathsFromOptions;
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
paths.push.apply(paths, pathsFromOptions);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (paths.length === 0) {
|
|
931
|
+
paths.push(path.resolve('.'));
|
|
932
|
+
}
|
|
933
|
+
var pathsCopy = __spreadArray([], paths, true);
|
|
934
|
+
var preparedPaths = [];
|
|
935
|
+
try {
|
|
936
|
+
var _loop_1 = function () {
|
|
937
|
+
var pathEntry = resolve(paths.shift());
|
|
938
|
+
if (pathEntry === null || pathEntry === void 0 ? void 0 : pathEntry.includes('*')) {
|
|
939
|
+
paths.push.apply(paths, findMatch(path.dirname(pathEntry), [path.basename(pathEntry)]));
|
|
940
|
+
return "continue";
|
|
941
|
+
}
|
|
942
|
+
if (fs.lstatSync(pathEntry).isDirectory()) {
|
|
943
|
+
preparedPaths.push.apply(preparedPaths, fs.readdirSync(pathEntry).map(function (file) { return path.join(pathEntry, file); }));
|
|
944
|
+
}
|
|
945
|
+
else {
|
|
946
|
+
preparedPaths.push(pathEntry);
|
|
947
|
+
}
|
|
948
|
+
};
|
|
949
|
+
while (paths.length > 0) {
|
|
950
|
+
_loop_1();
|
|
951
|
+
}
|
|
952
|
+
var entries = [];
|
|
953
|
+
var _loop_2 = function () {
|
|
954
|
+
var entry = preparedPaths.shift();
|
|
955
|
+
var entrybasename = path.basename(entry);
|
|
956
|
+
if (entry === null || entry === void 0 ? void 0 : entry.includes('*')) {
|
|
957
|
+
preparedPaths.push.apply(preparedPaths, findMatch(path.dirname(entry), [entrybasename]));
|
|
958
|
+
return "continue";
|
|
959
|
+
}
|
|
960
|
+
if (!includeHidden && entrybasename.startsWith('.') && entrybasename !== '.' && entrybasename !== '..') {
|
|
961
|
+
return "continue";
|
|
962
|
+
}
|
|
963
|
+
var baseDir = pathsCopy.find(function (p) { return entry.startsWith(path.resolve(p)); }) || path.resolve('.');
|
|
964
|
+
if (fs.lstatSync(entry).isDirectory() && isRecursive) {
|
|
965
|
+
preparedPaths.push.apply(preparedPaths, fs.readdirSync(entry).map(function (x) { return path.join(entry, x); }));
|
|
966
|
+
entries.push(path.relative(baseDir, entry));
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
entries.push(path.relative(baseDir, entry));
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
while (preparedPaths.length > 0) {
|
|
973
|
+
_loop_2();
|
|
974
|
+
}
|
|
975
|
+
return entries;
|
|
976
|
+
}
|
|
977
|
+
catch (error) {
|
|
978
|
+
if (error.code === 'ENOENT') {
|
|
979
|
+
throw new Error((0, exports.loc)('LIB_PathNotFound', 'ls', error.message));
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
throw new Error((0, exports.loc)('LIB_OperationFailed', 'ls', error));
|
|
983
|
+
}
|
|
772
984
|
}
|
|
773
985
|
}
|
|
774
986
|
exports.ls = ls;
|
|
775
987
|
/**
|
|
776
988
|
* Copies a file or folder.
|
|
777
|
-
*
|
|
778
|
-
* @param
|
|
779
|
-
* @param
|
|
780
|
-
* @param
|
|
781
|
-
* @param
|
|
782
|
-
* @
|
|
783
|
-
*/
|
|
784
|
-
function cp(
|
|
989
|
+
* @param {string} sourceOrOptions - Either the source path or an option string '-r', '-f' , '-n' or '-rfn' for recursive, force and no-clobber.
|
|
990
|
+
* @param {string} destinationOrSource - Destination path or the source path.
|
|
991
|
+
* @param {string} [optionsOrDestination] - Options string or the destination path.
|
|
992
|
+
* @param {boolean} [continueOnError=false] - Optional. Whether to continue on error.
|
|
993
|
+
* @param {number} [retryCount=0] - Optional. Retry count to copy the file. It might help to resolve intermittent issues e.g. with UNC target paths on a remote host.
|
|
994
|
+
* @returns {void}
|
|
995
|
+
*/
|
|
996
|
+
function cp(sourceOrOptions, destinationOrSource, optionsOrDestination, continueOnError, retryCount) {
|
|
997
|
+
if (continueOnError === void 0) { continueOnError = false; }
|
|
785
998
|
if (retryCount === void 0) { retryCount = 0; }
|
|
786
|
-
|
|
999
|
+
retry(function () {
|
|
1000
|
+
var recursive = false;
|
|
1001
|
+
var force = true;
|
|
1002
|
+
var source = String(sourceOrOptions);
|
|
1003
|
+
var destination = destinationOrSource;
|
|
1004
|
+
var options = '';
|
|
1005
|
+
if (typeof sourceOrOptions === 'string' && sourceOrOptions.startsWith('-')) {
|
|
1006
|
+
options = sourceOrOptions.toLowerCase();
|
|
1007
|
+
recursive = options.includes('r');
|
|
1008
|
+
force = !options.includes('n');
|
|
1009
|
+
source = destinationOrSource;
|
|
1010
|
+
destination = String(optionsOrDestination);
|
|
1011
|
+
}
|
|
1012
|
+
else if (typeof optionsOrDestination === 'string' && optionsOrDestination && optionsOrDestination.startsWith('-')) {
|
|
1013
|
+
options = optionsOrDestination.toLowerCase();
|
|
1014
|
+
recursive = options.includes('r');
|
|
1015
|
+
force = !options.includes('n');
|
|
1016
|
+
source = String(sourceOrOptions);
|
|
1017
|
+
destination = destinationOrSource;
|
|
1018
|
+
}
|
|
1019
|
+
if (!fs.existsSync(destination) && !force) {
|
|
1020
|
+
throw new Error((0, exports.loc)('LIB_PathNotFound', 'cp', destination));
|
|
1021
|
+
}
|
|
1022
|
+
var lstatSource = fs.lstatSync(source);
|
|
1023
|
+
if (!force && fs.existsSync(destination)) {
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
787
1026
|
try {
|
|
788
|
-
if (
|
|
789
|
-
|
|
1027
|
+
if (lstatSource.isSymbolicLink()) {
|
|
1028
|
+
var symlinkTarget = fs.readlinkSync(source);
|
|
1029
|
+
source = path.resolve(path.dirname(source), symlinkTarget);
|
|
1030
|
+
lstatSource = fs.lstatSync(source);
|
|
790
1031
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
catch (e) {
|
|
798
|
-
if (retryCount <= 0) {
|
|
799
|
-
if (continueOnError) {
|
|
800
|
-
exports.warning(e);
|
|
801
|
-
break;
|
|
1032
|
+
if (lstatSource.isFile()) {
|
|
1033
|
+
if (fs.existsSync(destination) && fs.lstatSync(destination).isDirectory()) {
|
|
1034
|
+
destination = path.join(destination, path.basename(source));
|
|
1035
|
+
}
|
|
1036
|
+
if (force) {
|
|
1037
|
+
fs.copyFileSync(source, destination);
|
|
802
1038
|
}
|
|
803
1039
|
else {
|
|
804
|
-
|
|
1040
|
+
fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
|
|
805
1041
|
}
|
|
806
1042
|
}
|
|
807
1043
|
else {
|
|
808
|
-
|
|
809
|
-
retryCount--;
|
|
1044
|
+
copyDirectoryWithResolvedSymlinks(source, path.join(destination, path.basename(source)), force);
|
|
810
1045
|
}
|
|
811
1046
|
}
|
|
812
|
-
|
|
1047
|
+
catch (error) {
|
|
1048
|
+
throw new Error((0, exports.loc)('LIB_OperationFailed', 'cp', error));
|
|
1049
|
+
}
|
|
1050
|
+
}, [], { retryCount: retryCount, continueOnError: continueOnError });
|
|
813
1051
|
}
|
|
814
1052
|
exports.cp = cp;
|
|
1053
|
+
var copyDirectoryWithResolvedSymlinks = function (src, dest, force) {
|
|
1054
|
+
var srcPath;
|
|
1055
|
+
var destPath;
|
|
1056
|
+
var entry;
|
|
1057
|
+
var entries = fs.readdirSync(src, { withFileTypes: true });
|
|
1058
|
+
if (!fs.existsSync(dest)) {
|
|
1059
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
1060
|
+
}
|
|
1061
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
1062
|
+
entry = entries_1[_i];
|
|
1063
|
+
srcPath = path.join(src, entry.name);
|
|
1064
|
+
destPath = path.join(dest, entry.name);
|
|
1065
|
+
if (entry.isSymbolicLink()) {
|
|
1066
|
+
// Resolve the symbolic link and copy the target
|
|
1067
|
+
var symlinkTarget = fs.readlinkSync(srcPath);
|
|
1068
|
+
var resolvedPath = path.resolve(path.dirname(srcPath), symlinkTarget);
|
|
1069
|
+
var stat = fs.lstatSync(resolvedPath);
|
|
1070
|
+
if (stat.isFile()) {
|
|
1071
|
+
// Use the actual target file's name instead of the symbolic link's name
|
|
1072
|
+
var targetFileName = path.basename(resolvedPath);
|
|
1073
|
+
var targetDestPath = path.join(dest, targetFileName);
|
|
1074
|
+
fs.copyFileSync(resolvedPath, targetDestPath);
|
|
1075
|
+
}
|
|
1076
|
+
else if (stat.isDirectory()) {
|
|
1077
|
+
copyDirectoryWithResolvedSymlinks(resolvedPath, destPath, force);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
else if (entry.isFile()) {
|
|
1081
|
+
fs.copyFileSync(srcPath, destPath);
|
|
1082
|
+
}
|
|
1083
|
+
else if (entry.isDirectory()) {
|
|
1084
|
+
copyDirectoryWithResolvedSymlinks(srcPath, destPath, force);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
815
1088
|
/**
|
|
816
1089
|
* Moves a path.
|
|
817
1090
|
*
|
|
818
|
-
* @param
|
|
819
|
-
* @param
|
|
820
|
-
* @param
|
|
821
|
-
* @param
|
|
1091
|
+
* @param {string} source - Source path.
|
|
1092
|
+
* @param {string} dest - Destination path.
|
|
1093
|
+
* @param {MoveOptionsVariants} [options] - Option string -f or -n for force and no clobber.
|
|
1094
|
+
* @param {boolean} [continueOnError] - Optional. Whether to continue on error.
|
|
1095
|
+
* @returns {void}
|
|
822
1096
|
*/
|
|
823
1097
|
function mv(source, dest, options, continueOnError) {
|
|
824
|
-
|
|
825
|
-
|
|
1098
|
+
var force = false;
|
|
1099
|
+
if (options && typeof options === 'string' && options.startsWith('-')) {
|
|
1100
|
+
var lowercasedOptions = String(options).toLowerCase();
|
|
1101
|
+
force = lowercasedOptions.includes('f') && !lowercasedOptions.includes('n');
|
|
1102
|
+
}
|
|
1103
|
+
var sourceExists = fs.existsSync(source);
|
|
1104
|
+
var destExists = fs.existsSync(dest);
|
|
1105
|
+
var sources = [];
|
|
1106
|
+
try {
|
|
1107
|
+
if (!sourceExists) {
|
|
1108
|
+
if (source.includes('*')) {
|
|
1109
|
+
sources.push.apply(sources, findMatch(path.resolve(path.dirname(source)), [path.basename(source)]));
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
throw new Error((0, exports.loc)('LIB_PathNotFound', 'mv', source));
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
else {
|
|
1116
|
+
sources.push(source);
|
|
1117
|
+
}
|
|
1118
|
+
if (destExists && !force) {
|
|
1119
|
+
throw new Error("File already exists at ".concat(dest));
|
|
1120
|
+
}
|
|
1121
|
+
for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
|
|
1122
|
+
var source_1 = sources_1[_i];
|
|
1123
|
+
fs.renameSync(source_1, dest);
|
|
1124
|
+
}
|
|
826
1125
|
}
|
|
827
|
-
|
|
828
|
-
|
|
1126
|
+
catch (error) {
|
|
1127
|
+
(0, exports.debug)('mv failed');
|
|
1128
|
+
var errMsg = (0, exports.loc)('LIB_OperationFailed', 'mv', error);
|
|
1129
|
+
(0, exports.debug)(errMsg);
|
|
1130
|
+
if (!continueOnError) {
|
|
1131
|
+
throw new Error(errMsg);
|
|
1132
|
+
}
|
|
829
1133
|
}
|
|
830
|
-
_checkShell('mv', continueOnError);
|
|
831
1134
|
}
|
|
832
1135
|
exports.mv = mv;
|
|
833
1136
|
/**
|
|
@@ -847,7 +1150,7 @@ function retry(func, args, retryOptions) {
|
|
|
847
1150
|
catch (e) {
|
|
848
1151
|
if (retryOptions.retryCount <= 0) {
|
|
849
1152
|
if (retryOptions.continueOnError) {
|
|
850
|
-
exports.warning(e);
|
|
1153
|
+
(0, exports.warning)(e, exports.IssueSource.TaskInternal);
|
|
851
1154
|
break;
|
|
852
1155
|
}
|
|
853
1156
|
else {
|
|
@@ -855,7 +1158,7 @@ function retry(func, args, retryOptions) {
|
|
|
855
1158
|
}
|
|
856
1159
|
}
|
|
857
1160
|
else {
|
|
858
|
-
exports.debug("Attempt to execute function \""
|
|
1161
|
+
(0, exports.debug)("Attempt to execute function \"".concat(func === null || func === void 0 ? void 0 : func.name, "\" failed, retries left: ").concat(retryOptions.retryCount));
|
|
859
1162
|
retryOptions.retryCount--;
|
|
860
1163
|
}
|
|
861
1164
|
}
|
|
@@ -883,7 +1186,7 @@ function _getStats(path, followSymbolicLink, allowBrokenSymbolicLinks) {
|
|
|
883
1186
|
if (err.code == 'ENOENT' && allowBrokenSymbolicLinks) {
|
|
884
1187
|
// fallback to lstat (broken symlinks allowed)
|
|
885
1188
|
stats = fs.lstatSync(path);
|
|
886
|
-
exports.debug(" "
|
|
1189
|
+
(0, exports.debug)(" ".concat(path, " (broken symlink)"));
|
|
887
1190
|
}
|
|
888
1191
|
else {
|
|
889
1192
|
throw err;
|
|
@@ -905,14 +1208,14 @@ function _getStats(path, followSymbolicLink, allowBrokenSymbolicLinks) {
|
|
|
905
1208
|
*/
|
|
906
1209
|
function find(findPath, options) {
|
|
907
1210
|
if (!findPath) {
|
|
908
|
-
exports.debug('no path specified');
|
|
1211
|
+
(0, exports.debug)('no path specified');
|
|
909
1212
|
return [];
|
|
910
1213
|
}
|
|
911
1214
|
// normalize the path, otherwise the first result is inconsistently formatted from the rest of the results
|
|
912
1215
|
// because path.join() performs normalization.
|
|
913
1216
|
findPath = path.normalize(findPath);
|
|
914
1217
|
// debug trace the parameters
|
|
915
|
-
exports.debug("findPath: '"
|
|
1218
|
+
(0, exports.debug)("findPath: '".concat(findPath, "'"));
|
|
916
1219
|
options = options || _getDefaultFindOptions();
|
|
917
1220
|
_debugFindOptions(options);
|
|
918
1221
|
// return empty if not exists
|
|
@@ -921,7 +1224,7 @@ function find(findPath, options) {
|
|
|
921
1224
|
}
|
|
922
1225
|
catch (err) {
|
|
923
1226
|
if (err.code == 'ENOENT') {
|
|
924
|
-
exports.debug('0 results');
|
|
1227
|
+
(0, exports.debug)('0 results');
|
|
925
1228
|
return [];
|
|
926
1229
|
}
|
|
927
1230
|
throw err;
|
|
@@ -931,7 +1234,7 @@ function find(findPath, options) {
|
|
|
931
1234
|
// push the first item
|
|
932
1235
|
var stack = [new _FindItem(findPath, 1)];
|
|
933
1236
|
var traversalChain = []; // used to detect cycles
|
|
934
|
-
var
|
|
1237
|
+
var _loop_3 = function () {
|
|
935
1238
|
// pop the next item and push to the result array
|
|
936
1239
|
var item = stack.pop(); // non-null because `stack.length` was truthy
|
|
937
1240
|
var stats_2 = void 0;
|
|
@@ -947,7 +1250,7 @@ function find(findPath, options) {
|
|
|
947
1250
|
}
|
|
948
1251
|
catch (err) {
|
|
949
1252
|
if (err.code == 'ENOENT' && options.skipMissingFiles) {
|
|
950
|
-
exports.warning("No such file or directory: \""
|
|
1253
|
+
(0, exports.warning)("No such file or directory: \"".concat(item.path, "\" - skipping."), exports.IssueSource.TaskInternal);
|
|
951
1254
|
return "continue";
|
|
952
1255
|
}
|
|
953
1256
|
throw err;
|
|
@@ -955,7 +1258,7 @@ function find(findPath, options) {
|
|
|
955
1258
|
result.push(item.path);
|
|
956
1259
|
// note, isDirectory() returns false for the lstat of a symlink
|
|
957
1260
|
if (stats_2.isDirectory()) {
|
|
958
|
-
exports.debug(" "
|
|
1261
|
+
(0, exports.debug)(" ".concat(item.path, " (directory)"));
|
|
959
1262
|
if (options.followSymbolicLinks) {
|
|
960
1263
|
// get the realpath
|
|
961
1264
|
var realPath_1;
|
|
@@ -972,7 +1275,7 @@ function find(findPath, options) {
|
|
|
972
1275
|
}
|
|
973
1276
|
// test for a cycle
|
|
974
1277
|
if (traversalChain.some(function (x) { return x == realPath_1; })) {
|
|
975
|
-
exports.debug(' cycle detected');
|
|
1278
|
+
(0, exports.debug)(' cycle detected');
|
|
976
1279
|
return "continue";
|
|
977
1280
|
}
|
|
978
1281
|
// update the traversal chain
|
|
@@ -987,17 +1290,17 @@ function find(findPath, options) {
|
|
|
987
1290
|
}
|
|
988
1291
|
}
|
|
989
1292
|
else {
|
|
990
|
-
exports.debug(" "
|
|
1293
|
+
(0, exports.debug)(" ".concat(item.path, " (file)"));
|
|
991
1294
|
}
|
|
992
1295
|
};
|
|
993
1296
|
while (stack.length) {
|
|
994
|
-
|
|
1297
|
+
_loop_3();
|
|
995
1298
|
}
|
|
996
|
-
exports.debug(result.length
|
|
1299
|
+
(0, exports.debug)("".concat(result.length, " results"));
|
|
997
1300
|
return result;
|
|
998
1301
|
}
|
|
999
1302
|
catch (err) {
|
|
1000
|
-
throw new Error(exports.loc('LIB_OperationFailed', 'find', err.message));
|
|
1303
|
+
throw new Error((0, exports.loc)('LIB_OperationFailed', 'find', err.message));
|
|
1001
1304
|
}
|
|
1002
1305
|
}
|
|
1003
1306
|
exports.find = find;
|
|
@@ -1009,10 +1312,10 @@ var _FindItem = /** @class */ (function () {
|
|
|
1009
1312
|
return _FindItem;
|
|
1010
1313
|
}());
|
|
1011
1314
|
function _debugFindOptions(options) {
|
|
1012
|
-
exports.debug("findOptions.allowBrokenSymbolicLinks: '"
|
|
1013
|
-
exports.debug("findOptions.followSpecifiedSymbolicLink: '"
|
|
1014
|
-
exports.debug("findOptions.followSymbolicLinks: '"
|
|
1015
|
-
exports.debug("findOptions.skipMissingFiles: '"
|
|
1315
|
+
(0, exports.debug)("findOptions.allowBrokenSymbolicLinks: '".concat(options.allowBrokenSymbolicLinks, "'"));
|
|
1316
|
+
(0, exports.debug)("findOptions.followSpecifiedSymbolicLink: '".concat(options.followSpecifiedSymbolicLink, "'"));
|
|
1317
|
+
(0, exports.debug)("findOptions.followSymbolicLinks: '".concat(options.followSymbolicLinks, "'"));
|
|
1318
|
+
(0, exports.debug)("findOptions.skipMissingFiles: '".concat(options.skipMissingFiles, "'"));
|
|
1016
1319
|
}
|
|
1017
1320
|
function _getDefaultFindOptions() {
|
|
1018
1321
|
return {
|
|
@@ -1036,10 +1339,10 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
|
|
|
1036
1339
|
if (!pattern) {
|
|
1037
1340
|
throw new Error('pattern parameter cannot be empty');
|
|
1038
1341
|
}
|
|
1039
|
-
exports.debug("legacyFindFiles rootDirectory: '"
|
|
1040
|
-
exports.debug("pattern: '"
|
|
1041
|
-
exports.debug("includeFiles: '"
|
|
1042
|
-
exports.debug("includeDirectories: '"
|
|
1342
|
+
(0, exports.debug)("legacyFindFiles rootDirectory: '".concat(rootDirectory, "'"));
|
|
1343
|
+
(0, exports.debug)("pattern: '".concat(pattern, "'"));
|
|
1344
|
+
(0, exports.debug)("includeFiles: '".concat(includeFiles, "'"));
|
|
1345
|
+
(0, exports.debug)("includeDirectories: '".concat(includeDirectories, "'"));
|
|
1043
1346
|
if (!includeFiles && !includeDirectories) {
|
|
1044
1347
|
includeFiles = true;
|
|
1045
1348
|
}
|
|
@@ -1070,7 +1373,7 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
|
|
|
1070
1373
|
}
|
|
1071
1374
|
// validate pattern does not end with a slash
|
|
1072
1375
|
if (im._endsWith(pat, '/') || (process.platform == 'win32' && im._endsWith(pat, '\\'))) {
|
|
1073
|
-
throw new Error(exports.loc('LIB_InvalidPattern', pat));
|
|
1376
|
+
throw new Error((0, exports.loc)('LIB_InvalidPattern', pat));
|
|
1074
1377
|
}
|
|
1075
1378
|
// root the pattern
|
|
1076
1379
|
if (rootDirectory && !path.isAbsolute(pat)) {
|
|
@@ -1092,29 +1395,29 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
|
|
|
1092
1395
|
// find and apply patterns
|
|
1093
1396
|
var count = 0;
|
|
1094
1397
|
var result = _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, !!includeFiles, !!includeDirectories);
|
|
1095
|
-
exports.debug('all matches:');
|
|
1398
|
+
(0, exports.debug)('all matches:');
|
|
1096
1399
|
for (var _b = 0, result_1 = result; _b < result_1.length; _b++) {
|
|
1097
1400
|
var resultItem = result_1[_b];
|
|
1098
|
-
exports.debug(' ' + resultItem);
|
|
1401
|
+
(0, exports.debug)(' ' + resultItem);
|
|
1099
1402
|
}
|
|
1100
|
-
exports.debug('total matched: ' + result.length);
|
|
1403
|
+
(0, exports.debug)('total matched: ' + result.length);
|
|
1101
1404
|
return result;
|
|
1102
1405
|
}
|
|
1103
1406
|
exports.legacyFindFiles = legacyFindFiles;
|
|
1104
1407
|
function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, includeFiles, includeDirectories) {
|
|
1105
|
-
exports.debug('getMatchingItems()');
|
|
1408
|
+
(0, exports.debug)('getMatchingItems()');
|
|
1106
1409
|
for (var _i = 0, includePatterns_1 = includePatterns; _i < includePatterns_1.length; _i++) {
|
|
1107
1410
|
var pattern = includePatterns_1[_i];
|
|
1108
|
-
exports.debug("includePattern: '"
|
|
1411
|
+
(0, exports.debug)("includePattern: '".concat(pattern, "'"));
|
|
1109
1412
|
}
|
|
1110
1413
|
for (var _a = 0, excludePatterns_1 = excludePatterns; _a < excludePatterns_1.length; _a++) {
|
|
1111
1414
|
var pattern = excludePatterns_1[_a];
|
|
1112
|
-
exports.debug("excludePattern: "
|
|
1415
|
+
(0, exports.debug)("excludePattern: ".concat(pattern));
|
|
1113
1416
|
}
|
|
1114
|
-
exports.debug('includeFiles: ' + includeFiles);
|
|
1115
|
-
exports.debug('includeDirectories: ' + includeDirectories);
|
|
1417
|
+
(0, exports.debug)('includeFiles: ' + includeFiles);
|
|
1418
|
+
(0, exports.debug)('includeDirectories: ' + includeDirectories);
|
|
1116
1419
|
var allFiles = {};
|
|
1117
|
-
var
|
|
1420
|
+
var _loop_4 = function (pattern) {
|
|
1118
1421
|
// determine the directory to search
|
|
1119
1422
|
//
|
|
1120
1423
|
// note, getDirectoryName removes redundant path separators
|
|
@@ -1155,7 +1458,7 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
|
|
|
1155
1458
|
var normalizedPath = process.platform == 'win32' ? item.replace(/\\/g, '/') : item; // normalize separators
|
|
1156
1459
|
// **/times/** will not match C:/fun/times because there isn't a trailing slash
|
|
1157
1460
|
// so try both if including directories
|
|
1158
|
-
var alternatePath = normalizedPath
|
|
1461
|
+
var alternatePath = "".concat(normalizedPath, "/"); // potential bug: it looks like this will result in a false
|
|
1159
1462
|
// positive if the item is a regular file and not a directory
|
|
1160
1463
|
var isMatch = false;
|
|
1161
1464
|
if (patternRegex.test(normalizedPath) || (includeDirectories && patternRegex.test(alternatePath))) {
|
|
@@ -1176,80 +1479,103 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
|
|
|
1176
1479
|
};
|
|
1177
1480
|
for (var _b = 0, includePatterns_2 = includePatterns; _b < includePatterns_2.length; _b++) {
|
|
1178
1481
|
var pattern = includePatterns_2[_b];
|
|
1179
|
-
|
|
1482
|
+
_loop_4(pattern);
|
|
1180
1483
|
}
|
|
1181
1484
|
return Object.keys(allFiles).sort();
|
|
1182
1485
|
}
|
|
1183
1486
|
/**
|
|
1184
1487
|
* Remove a path recursively with force
|
|
1185
1488
|
*
|
|
1186
|
-
* @param
|
|
1187
|
-
* @
|
|
1489
|
+
* @param {string} inputPath - Path to remove
|
|
1490
|
+
* @return {void}
|
|
1491
|
+
* @throws When the file or directory exists but could not be deleted.
|
|
1188
1492
|
*/
|
|
1189
1493
|
function rmRF(inputPath) {
|
|
1190
|
-
exports.debug('rm -rf ' + inputPath);
|
|
1494
|
+
(0, exports.debug)('rm -rf ' + inputPath);
|
|
1191
1495
|
if (getPlatform() == Platform.Windows) {
|
|
1192
1496
|
// Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
|
|
1193
1497
|
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
|
1194
1498
|
try {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1499
|
+
var lstats = fs.lstatSync(inputPath);
|
|
1500
|
+
if (lstats.isDirectory() && !lstats.isSymbolicLink()) {
|
|
1501
|
+
(0, exports.debug)('removing directory ' + inputPath);
|
|
1502
|
+
childProcess.execFileSync("cmd.exe", ["/c", "rd", "/s", "/q", inputPath]);
|
|
1503
|
+
}
|
|
1504
|
+
else if (lstats.isSymbolicLink()) {
|
|
1505
|
+
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1506
|
+
var realPath = fs.readlinkSync(inputPath);
|
|
1507
|
+
if (fs.existsSync(realPath)) {
|
|
1508
|
+
var stats_3 = fs.statSync(realPath);
|
|
1509
|
+
if (stats_3.isDirectory()) {
|
|
1510
|
+
childProcess.execFileSync("cmd.exe", ["/c", "rd", "/s", "/q", realPath]);
|
|
1511
|
+
fs.unlinkSync(inputPath);
|
|
1512
|
+
}
|
|
1513
|
+
else {
|
|
1514
|
+
fs.unlinkSync(inputPath);
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
else {
|
|
1518
|
+
(0, exports.debug)("Symbolic link '".concat(inputPath, "' points to a non-existing target '").concat(realPath, "'. Removing the symbolic link."));
|
|
1519
|
+
fs.unlinkSync(inputPath);
|
|
1520
|
+
}
|
|
1198
1521
|
}
|
|
1199
1522
|
else {
|
|
1200
|
-
exports.debug('removing file ' + inputPath);
|
|
1201
|
-
childProcess.
|
|
1523
|
+
(0, exports.debug)('removing file ' + inputPath);
|
|
1524
|
+
childProcess.execFileSync("cmd.exe", ["/c", "del", "/f", "/a", inputPath]);
|
|
1202
1525
|
}
|
|
1203
1526
|
}
|
|
1204
1527
|
catch (err) {
|
|
1205
|
-
|
|
1206
|
-
// other errors are valid
|
|
1528
|
+
(0, exports.debug)('Error: ' + err.message);
|
|
1207
1529
|
if (err.code != 'ENOENT') {
|
|
1208
|
-
throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
// Shelling out fails to remove a symlink folder with missing source, this unlink catches that
|
|
1212
|
-
try {
|
|
1213
|
-
fs.unlinkSync(inputPath);
|
|
1214
|
-
}
|
|
1215
|
-
catch (err) {
|
|
1216
|
-
// if you try to delete a file that doesn't exist, desired result is achieved
|
|
1217
|
-
// other errors are valid
|
|
1218
|
-
if (err.code != 'ENOENT') {
|
|
1219
|
-
throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
|
|
1530
|
+
throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
|
|
1220
1531
|
}
|
|
1221
1532
|
}
|
|
1222
1533
|
}
|
|
1223
1534
|
else {
|
|
1224
|
-
// get the lstats in order to workaround a bug in shelljs@0.3.0 where symlinks
|
|
1225
|
-
// with missing targets are not handled correctly by "rm('-rf', path)"
|
|
1226
1535
|
var lstats = void 0;
|
|
1227
1536
|
try {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
return;
|
|
1537
|
+
if (inputPath.includes('*')) {
|
|
1538
|
+
var entries = findMatch(path.dirname(inputPath), [path.basename(inputPath)]);
|
|
1539
|
+
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
1540
|
+
var entry = entries_2[_i];
|
|
1541
|
+
rmRF(entry);
|
|
1542
|
+
}
|
|
1235
1543
|
}
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1544
|
+
else {
|
|
1545
|
+
lstats = fs.lstatSync(inputPath);
|
|
1546
|
+
if (lstats.isDirectory() && !lstats.isSymbolicLink()) {
|
|
1547
|
+
(0, exports.debug)('removing directory ' + inputPath);
|
|
1548
|
+
fs.rmSync(inputPath, { recursive: true, force: true });
|
|
1549
|
+
}
|
|
1550
|
+
else if (lstats.isSymbolicLink()) {
|
|
1551
|
+
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1552
|
+
var realPath = fs.readlinkSync(inputPath);
|
|
1553
|
+
if (fs.existsSync(realPath)) {
|
|
1554
|
+
var stats_4 = fs.statSync(realPath);
|
|
1555
|
+
if (stats_4.isDirectory()) {
|
|
1556
|
+
fs.rmSync(realPath, { recursive: true, force: true });
|
|
1557
|
+
fs.unlinkSync(inputPath);
|
|
1558
|
+
}
|
|
1559
|
+
else {
|
|
1560
|
+
fs.unlinkSync(inputPath);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
else {
|
|
1564
|
+
(0, exports.debug)("Symbolic link '".concat(inputPath, "' points to a non-existing target '").concat(realPath, "'. Removing the symbolic link."));
|
|
1565
|
+
fs.unlinkSync(inputPath);
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1568
|
+
else {
|
|
1569
|
+
(0, exports.debug)('removing file ' + inputPath);
|
|
1570
|
+
fs.unlinkSync(inputPath);
|
|
1571
|
+
}
|
|
1244
1572
|
}
|
|
1245
|
-
return;
|
|
1246
|
-
}
|
|
1247
|
-
exports.debug('removing file');
|
|
1248
|
-
try {
|
|
1249
|
-
fs.unlinkSync(inputPath);
|
|
1250
1573
|
}
|
|
1251
1574
|
catch (err) {
|
|
1252
|
-
|
|
1575
|
+
(0, exports.debug)('Error: ' + err.message);
|
|
1576
|
+
if (err.code != 'ENOENT') {
|
|
1577
|
+
throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
|
|
1578
|
+
}
|
|
1253
1579
|
}
|
|
1254
1580
|
}
|
|
1255
1581
|
}
|
|
@@ -1264,11 +1590,32 @@ exports.rmRF = rmRF;
|
|
|
1264
1590
|
* @param options optional exec options. See IExecOptions
|
|
1265
1591
|
* @returns number
|
|
1266
1592
|
*/
|
|
1593
|
+
function execAsync(tool, args, options) {
|
|
1594
|
+
var tr = this.tool(tool);
|
|
1595
|
+
if (args) {
|
|
1596
|
+
if (args instanceof Array) {
|
|
1597
|
+
tr.arg(args);
|
|
1598
|
+
}
|
|
1599
|
+
else if (typeof (args) === 'string') {
|
|
1600
|
+
tr.line(args);
|
|
1601
|
+
}
|
|
1602
|
+
}
|
|
1603
|
+
return tr.execAsync(options);
|
|
1604
|
+
}
|
|
1605
|
+
exports.execAsync = execAsync;
|
|
1606
|
+
/**
|
|
1607
|
+
* Exec a tool. Convenience wrapper over ToolRunner to exec with args in one call.
|
|
1608
|
+
* Output will be streamed to the live console.
|
|
1609
|
+
* Returns promise with return code
|
|
1610
|
+
*
|
|
1611
|
+
* @deprecated Use the {@link execAsync} method that returns a native Javascript Promise instead
|
|
1612
|
+
* @param tool path to tool to exec
|
|
1613
|
+
* @param args an arg string or array of args
|
|
1614
|
+
* @param options optional exec options. See IExecOptions
|
|
1615
|
+
* @returns number
|
|
1616
|
+
*/
|
|
1267
1617
|
function exec(tool, args, options) {
|
|
1268
1618
|
var tr = this.tool(tool);
|
|
1269
|
-
tr.on('debug', function (data) {
|
|
1270
|
-
exports.debug(data);
|
|
1271
|
-
});
|
|
1272
1619
|
if (args) {
|
|
1273
1620
|
if (args instanceof Array) {
|
|
1274
1621
|
tr.arg(args);
|
|
@@ -1293,9 +1640,6 @@ exports.exec = exec;
|
|
|
1293
1640
|
*/
|
|
1294
1641
|
function execSync(tool, args, options) {
|
|
1295
1642
|
var tr = this.tool(tool);
|
|
1296
|
-
tr.on('debug', function (data) {
|
|
1297
|
-
exports.debug(data);
|
|
1298
|
-
});
|
|
1299
1643
|
if (args) {
|
|
1300
1644
|
if (args instanceof Array) {
|
|
1301
1645
|
tr.arg(args);
|
|
@@ -1316,7 +1660,7 @@ exports.execSync = execSync;
|
|
|
1316
1660
|
function tool(tool) {
|
|
1317
1661
|
var tr = new trm.ToolRunner(tool);
|
|
1318
1662
|
tr.on('debug', function (message) {
|
|
1319
|
-
exports.debug(message);
|
|
1663
|
+
(0, exports.debug)(message);
|
|
1320
1664
|
});
|
|
1321
1665
|
return tr;
|
|
1322
1666
|
}
|
|
@@ -1331,7 +1675,7 @@ exports.tool = tool;
|
|
|
1331
1675
|
*/
|
|
1332
1676
|
function match(list, patterns, patternRoot, options) {
|
|
1333
1677
|
// trace parameters
|
|
1334
|
-
exports.debug("patternRoot: '"
|
|
1678
|
+
(0, exports.debug)("patternRoot: '".concat(patternRoot, "'"));
|
|
1335
1679
|
options = options || _getDefaultMatchOptions(); // default match options
|
|
1336
1680
|
_debugMatchOptions(options);
|
|
1337
1681
|
// convert pattern to an array
|
|
@@ -1343,18 +1687,18 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1343
1687
|
var originalOptions = options;
|
|
1344
1688
|
for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
|
|
1345
1689
|
var pattern = patterns_1[_i];
|
|
1346
|
-
exports.debug("pattern: '"
|
|
1690
|
+
(0, exports.debug)("pattern: '".concat(pattern, "'"));
|
|
1347
1691
|
// trim and skip empty
|
|
1348
1692
|
pattern = (pattern || '').trim();
|
|
1349
1693
|
if (!pattern) {
|
|
1350
|
-
exports.debug('skipping empty pattern');
|
|
1694
|
+
(0, exports.debug)('skipping empty pattern');
|
|
1351
1695
|
continue;
|
|
1352
1696
|
}
|
|
1353
1697
|
// clone match options
|
|
1354
1698
|
var options_1 = im._cloneMatchOptions(originalOptions);
|
|
1355
1699
|
// skip comments
|
|
1356
1700
|
if (!options_1.nocomment && im._startsWith(pattern, '#')) {
|
|
1357
|
-
exports.debug('skipping comment');
|
|
1701
|
+
(0, exports.debug)('skipping comment');
|
|
1358
1702
|
continue;
|
|
1359
1703
|
}
|
|
1360
1704
|
// set nocomment - brace expansion could result in a leading '#'
|
|
@@ -1367,7 +1711,7 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1367
1711
|
}
|
|
1368
1712
|
pattern = pattern.substring(negateCount); // trim leading '!'
|
|
1369
1713
|
if (negateCount) {
|
|
1370
|
-
exports.debug("trimmed leading '!'. pattern: '"
|
|
1714
|
+
(0, exports.debug)("trimmed leading '!'. pattern: '".concat(pattern, "'"));
|
|
1371
1715
|
}
|
|
1372
1716
|
}
|
|
1373
1717
|
var isIncludePattern = negateCount == 0 ||
|
|
@@ -1385,7 +1729,7 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1385
1729
|
else {
|
|
1386
1730
|
// convert slashes on Windows before calling braceExpand(). unfortunately this means braces cannot
|
|
1387
1731
|
// be escaped on Windows, this limitation is consistent with current limitations of minimatch (3.0.3).
|
|
1388
|
-
exports.debug('expanding braces');
|
|
1732
|
+
(0, exports.debug)('expanding braces');
|
|
1389
1733
|
var convertedPattern = process.platform == 'win32' ? pattern.replace(/\\/g, '/') : pattern;
|
|
1390
1734
|
expanded = minimatch.braceExpand(convertedPattern);
|
|
1391
1735
|
}
|
|
@@ -1394,12 +1738,12 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1394
1738
|
for (var _a = 0, expanded_1 = expanded; _a < expanded_1.length; _a++) {
|
|
1395
1739
|
var pattern_1 = expanded_1[_a];
|
|
1396
1740
|
if (expanded.length != 1 || pattern_1 != preExpanded) {
|
|
1397
|
-
exports.debug("pattern: '"
|
|
1741
|
+
(0, exports.debug)("pattern: '".concat(pattern_1, "'"));
|
|
1398
1742
|
}
|
|
1399
1743
|
// trim and skip empty
|
|
1400
1744
|
pattern_1 = (pattern_1 || '').trim();
|
|
1401
1745
|
if (!pattern_1) {
|
|
1402
|
-
exports.debug('skipping empty pattern');
|
|
1746
|
+
(0, exports.debug)('skipping empty pattern');
|
|
1403
1747
|
continue;
|
|
1404
1748
|
}
|
|
1405
1749
|
// root the pattern when all of the following conditions are true:
|
|
@@ -1408,13 +1752,13 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1408
1752
|
// AND matchBase:false or not basename only
|
|
1409
1753
|
(!options_1.matchBase || (process.platform == 'win32' ? pattern_1.replace(/\\/g, '/') : pattern_1).indexOf('/') >= 0)) {
|
|
1410
1754
|
pattern_1 = im._ensureRooted(patternRoot, pattern_1);
|
|
1411
|
-
exports.debug("rooted pattern: '"
|
|
1755
|
+
(0, exports.debug)("rooted pattern: '".concat(pattern_1, "'"));
|
|
1412
1756
|
}
|
|
1413
1757
|
if (isIncludePattern) {
|
|
1414
1758
|
// apply the pattern
|
|
1415
|
-
exports.debug('applying include pattern against original list');
|
|
1759
|
+
(0, exports.debug)('applying include pattern against original list');
|
|
1416
1760
|
var matchResults = minimatch.match(list, pattern_1, options_1);
|
|
1417
|
-
exports.debug(matchResults.length + ' matches');
|
|
1761
|
+
(0, exports.debug)(matchResults.length + ' matches');
|
|
1418
1762
|
// union the results
|
|
1419
1763
|
for (var _b = 0, matchResults_1 = matchResults; _b < matchResults_1.length; _b++) {
|
|
1420
1764
|
var matchResult = matchResults_1[_b];
|
|
@@ -1423,9 +1767,9 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1423
1767
|
}
|
|
1424
1768
|
else {
|
|
1425
1769
|
// apply the pattern
|
|
1426
|
-
exports.debug('applying exclude pattern against original list');
|
|
1770
|
+
(0, exports.debug)('applying exclude pattern against original list');
|
|
1427
1771
|
var matchResults = minimatch.match(list, pattern_1, options_1);
|
|
1428
|
-
exports.debug(matchResults.length + ' matches');
|
|
1772
|
+
(0, exports.debug)(matchResults.length + ' matches');
|
|
1429
1773
|
// substract the results
|
|
1430
1774
|
for (var _c = 0, matchResults_2 = matchResults; _c < matchResults_2.length; _c++) {
|
|
1431
1775
|
var matchResult = matchResults_2[_c];
|
|
@@ -1436,7 +1780,7 @@ function match(list, patterns, patternRoot, options) {
|
|
|
1436
1780
|
}
|
|
1437
1781
|
// return a filtered version of the original list (preserves order and prevents duplication)
|
|
1438
1782
|
var result = list.filter(function (item) { return map.hasOwnProperty(item); });
|
|
1439
|
-
exports.debug(result.length + ' final results');
|
|
1783
|
+
(0, exports.debug)(result.length + ' final results');
|
|
1440
1784
|
return result;
|
|
1441
1785
|
}
|
|
1442
1786
|
exports.match = match;
|
|
@@ -1452,17 +1796,17 @@ function filter(pattern, options) {
|
|
|
1452
1796
|
}
|
|
1453
1797
|
exports.filter = filter;
|
|
1454
1798
|
function _debugMatchOptions(options) {
|
|
1455
|
-
exports.debug("matchOptions.debug: '"
|
|
1456
|
-
exports.debug("matchOptions.nobrace: '"
|
|
1457
|
-
exports.debug("matchOptions.noglobstar: '"
|
|
1458
|
-
exports.debug("matchOptions.dot: '"
|
|
1459
|
-
exports.debug("matchOptions.noext: '"
|
|
1460
|
-
exports.debug("matchOptions.nocase: '"
|
|
1461
|
-
exports.debug("matchOptions.nonull: '"
|
|
1462
|
-
exports.debug("matchOptions.matchBase: '"
|
|
1463
|
-
exports.debug("matchOptions.nocomment: '"
|
|
1464
|
-
exports.debug("matchOptions.nonegate: '"
|
|
1465
|
-
exports.debug("matchOptions.flipNegate: '"
|
|
1799
|
+
(0, exports.debug)("matchOptions.debug: '".concat(options.debug, "'"));
|
|
1800
|
+
(0, exports.debug)("matchOptions.nobrace: '".concat(options.nobrace, "'"));
|
|
1801
|
+
(0, exports.debug)("matchOptions.noglobstar: '".concat(options.noglobstar, "'"));
|
|
1802
|
+
(0, exports.debug)("matchOptions.dot: '".concat(options.dot, "'"));
|
|
1803
|
+
(0, exports.debug)("matchOptions.noext: '".concat(options.noext, "'"));
|
|
1804
|
+
(0, exports.debug)("matchOptions.nocase: '".concat(options.nocase, "'"));
|
|
1805
|
+
(0, exports.debug)("matchOptions.nonull: '".concat(options.nonull, "'"));
|
|
1806
|
+
(0, exports.debug)("matchOptions.matchBase: '".concat(options.matchBase, "'"));
|
|
1807
|
+
(0, exports.debug)("matchOptions.nocomment: '".concat(options.nocomment, "'"));
|
|
1808
|
+
(0, exports.debug)("matchOptions.nonegate: '".concat(options.nonegate, "'"));
|
|
1809
|
+
(0, exports.debug)("matchOptions.flipNegate: '".concat(options.flipNegate, "'"));
|
|
1466
1810
|
}
|
|
1467
1811
|
function _getDefaultMatchOptions() {
|
|
1468
1812
|
return {
|
|
@@ -1493,7 +1837,7 @@ function _getDefaultMatchOptions() {
|
|
|
1493
1837
|
function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
1494
1838
|
// apply defaults for parameters and trace
|
|
1495
1839
|
defaultRoot = defaultRoot || this.getVariable('system.defaultWorkingDirectory') || process.cwd();
|
|
1496
|
-
exports.debug("defaultRoot: '"
|
|
1840
|
+
(0, exports.debug)("defaultRoot: '".concat(defaultRoot, "'"));
|
|
1497
1841
|
patterns = patterns || [];
|
|
1498
1842
|
patterns = typeof patterns == 'string' ? [patterns] : patterns;
|
|
1499
1843
|
findOptions = findOptions || _getDefaultFindOptions();
|
|
@@ -1506,18 +1850,18 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1506
1850
|
var originalMatchOptions = matchOptions;
|
|
1507
1851
|
for (var _i = 0, _a = (patterns || []); _i < _a.length; _i++) {
|
|
1508
1852
|
var pattern = _a[_i];
|
|
1509
|
-
exports.debug("pattern: '"
|
|
1853
|
+
(0, exports.debug)("pattern: '".concat(pattern, "'"));
|
|
1510
1854
|
// trim and skip empty
|
|
1511
1855
|
pattern = (pattern || '').trim();
|
|
1512
1856
|
if (!pattern) {
|
|
1513
|
-
exports.debug('skipping empty pattern');
|
|
1857
|
+
(0, exports.debug)('skipping empty pattern');
|
|
1514
1858
|
continue;
|
|
1515
1859
|
}
|
|
1516
1860
|
// clone match options
|
|
1517
1861
|
var matchOptions_1 = im._cloneMatchOptions(originalMatchOptions);
|
|
1518
1862
|
// skip comments
|
|
1519
1863
|
if (!matchOptions_1.nocomment && im._startsWith(pattern, '#')) {
|
|
1520
|
-
exports.debug('skipping comment');
|
|
1864
|
+
(0, exports.debug)('skipping comment');
|
|
1521
1865
|
continue;
|
|
1522
1866
|
}
|
|
1523
1867
|
// set nocomment - brace expansion could result in a leading '#'
|
|
@@ -1530,7 +1874,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1530
1874
|
}
|
|
1531
1875
|
pattern = pattern.substring(negateCount); // trim leading '!'
|
|
1532
1876
|
if (negateCount) {
|
|
1533
|
-
exports.debug("trimmed leading '!'. pattern: '"
|
|
1877
|
+
(0, exports.debug)("trimmed leading '!'. pattern: '".concat(pattern, "'"));
|
|
1534
1878
|
}
|
|
1535
1879
|
}
|
|
1536
1880
|
var isIncludePattern = negateCount == 0 ||
|
|
@@ -1548,7 +1892,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1548
1892
|
else {
|
|
1549
1893
|
// convert slashes on Windows before calling braceExpand(). unfortunately this means braces cannot
|
|
1550
1894
|
// be escaped on Windows, this limitation is consistent with current limitations of minimatch (3.0.3).
|
|
1551
|
-
exports.debug('expanding braces');
|
|
1895
|
+
(0, exports.debug)('expanding braces');
|
|
1552
1896
|
var convertedPattern = process.platform == 'win32' ? pattern.replace(/\\/g, '/') : pattern;
|
|
1553
1897
|
expanded = minimatch.braceExpand(convertedPattern);
|
|
1554
1898
|
}
|
|
@@ -1557,25 +1901,25 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1557
1901
|
for (var _b = 0, expanded_2 = expanded; _b < expanded_2.length; _b++) {
|
|
1558
1902
|
var pattern_2 = expanded_2[_b];
|
|
1559
1903
|
if (expanded.length != 1 || pattern_2 != preExpanded) {
|
|
1560
|
-
exports.debug("pattern: '"
|
|
1904
|
+
(0, exports.debug)("pattern: '".concat(pattern_2, "'"));
|
|
1561
1905
|
}
|
|
1562
1906
|
// trim and skip empty
|
|
1563
1907
|
pattern_2 = (pattern_2 || '').trim();
|
|
1564
1908
|
if (!pattern_2) {
|
|
1565
|
-
exports.debug('skipping empty pattern');
|
|
1909
|
+
(0, exports.debug)('skipping empty pattern');
|
|
1566
1910
|
continue;
|
|
1567
1911
|
}
|
|
1568
1912
|
if (isIncludePattern) {
|
|
1569
1913
|
// determine the findPath
|
|
1570
1914
|
var findInfo = im._getFindInfoFromPattern(defaultRoot, pattern_2, matchOptions_1);
|
|
1571
1915
|
var findPath = findInfo.findPath;
|
|
1572
|
-
exports.debug("findPath: '"
|
|
1916
|
+
(0, exports.debug)("findPath: '".concat(findPath, "'"));
|
|
1573
1917
|
if (!findPath) {
|
|
1574
|
-
exports.debug('skipping empty path');
|
|
1918
|
+
(0, exports.debug)('skipping empty path');
|
|
1575
1919
|
continue;
|
|
1576
1920
|
}
|
|
1577
1921
|
// perform the find
|
|
1578
|
-
exports.debug("statOnly: '"
|
|
1922
|
+
(0, exports.debug)("statOnly: '".concat(findInfo.statOnly, "'"));
|
|
1579
1923
|
var findResults = [];
|
|
1580
1924
|
if (findInfo.statOnly) {
|
|
1581
1925
|
// simply stat the path - all path segments were used to build the path
|
|
@@ -1587,21 +1931,21 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1587
1931
|
if (err.code != 'ENOENT') {
|
|
1588
1932
|
throw err;
|
|
1589
1933
|
}
|
|
1590
|
-
exports.debug('ENOENT');
|
|
1934
|
+
(0, exports.debug)('ENOENT');
|
|
1591
1935
|
}
|
|
1592
1936
|
}
|
|
1593
1937
|
else {
|
|
1594
1938
|
findResults = find(findPath, findOptions);
|
|
1595
1939
|
}
|
|
1596
|
-
exports.debug("found "
|
|
1940
|
+
(0, exports.debug)("found ".concat(findResults.length, " paths"));
|
|
1597
1941
|
// apply the pattern
|
|
1598
|
-
exports.debug('applying include pattern');
|
|
1942
|
+
(0, exports.debug)('applying include pattern');
|
|
1599
1943
|
if (findInfo.adjustedPattern != pattern_2) {
|
|
1600
|
-
exports.debug("adjustedPattern: '"
|
|
1944
|
+
(0, exports.debug)("adjustedPattern: '".concat(findInfo.adjustedPattern, "'"));
|
|
1601
1945
|
pattern_2 = findInfo.adjustedPattern;
|
|
1602
1946
|
}
|
|
1603
1947
|
var matchResults = minimatch.match(findResults, pattern_2, matchOptions_1);
|
|
1604
|
-
exports.debug(matchResults.length + ' matches');
|
|
1948
|
+
(0, exports.debug)(matchResults.length + ' matches');
|
|
1605
1949
|
// union the results
|
|
1606
1950
|
for (var _c = 0, matchResults_3 = matchResults; _c < matchResults_3.length; _c++) {
|
|
1607
1951
|
var matchResult = matchResults_3[_c];
|
|
@@ -1615,17 +1959,17 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1615
1959
|
!im._isRooted(pattern_2) &&
|
|
1616
1960
|
(process.platform == 'win32' ? pattern_2.replace(/\\/g, '/') : pattern_2).indexOf('/') < 0) {
|
|
1617
1961
|
// do not root the pattern
|
|
1618
|
-
exports.debug('matchBase and basename only');
|
|
1962
|
+
(0, exports.debug)('matchBase and basename only');
|
|
1619
1963
|
}
|
|
1620
1964
|
else {
|
|
1621
1965
|
// root the exclude pattern
|
|
1622
1966
|
pattern_2 = im._ensurePatternRooted(defaultRoot, pattern_2);
|
|
1623
|
-
exports.debug("after ensurePatternRooted, pattern: '"
|
|
1967
|
+
(0, exports.debug)("after ensurePatternRooted, pattern: '".concat(pattern_2, "'"));
|
|
1624
1968
|
}
|
|
1625
1969
|
// apply the pattern
|
|
1626
|
-
exports.debug('applying exclude pattern');
|
|
1970
|
+
(0, exports.debug)('applying exclude pattern');
|
|
1627
1971
|
var matchResults = minimatch.match(Object.keys(results).map(function (key) { return results[key]; }), pattern_2, matchOptions_1);
|
|
1628
|
-
exports.debug(matchResults.length + ' matches');
|
|
1972
|
+
(0, exports.debug)(matchResults.length + ' matches');
|
|
1629
1973
|
// substract the results
|
|
1630
1974
|
for (var _d = 0, matchResults_4 = matchResults; _d < matchResults_4.length; _d++) {
|
|
1631
1975
|
var matchResult = matchResults_4[_d];
|
|
@@ -1638,7 +1982,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
|
|
|
1638
1982
|
var finalResult = Object.keys(results)
|
|
1639
1983
|
.map(function (key) { return results[key]; })
|
|
1640
1984
|
.sort();
|
|
1641
|
-
exports.debug(finalResult.length + ' final results');
|
|
1985
|
+
(0, exports.debug)(finalResult.length + ' final results');
|
|
1642
1986
|
return finalResult;
|
|
1643
1987
|
}
|
|
1644
1988
|
exports.findMatch = findMatch;
|
|
@@ -1651,9 +1995,9 @@ exports.findMatch = findMatch;
|
|
|
1651
1995
|
*/
|
|
1652
1996
|
function getProxyFormattedUrl(proxyUrl, proxyUsername, proxyPassword) {
|
|
1653
1997
|
var parsedUrl = new URL(proxyUrl);
|
|
1654
|
-
var proxyAddress = parsedUrl.protocol
|
|
1998
|
+
var proxyAddress = "".concat(parsedUrl.protocol, "//").concat(parsedUrl.host);
|
|
1655
1999
|
if (proxyUsername) {
|
|
1656
|
-
proxyAddress = parsedUrl.protocol
|
|
2000
|
+
proxyAddress = "".concat(parsedUrl.protocol, "//").concat(proxyUsername, ":").concat(proxyPassword, "@").concat(parsedUrl.host);
|
|
1657
2001
|
}
|
|
1658
2002
|
return proxyAddress;
|
|
1659
2003
|
}
|
|
@@ -1663,11 +2007,11 @@ function getProxyFormattedUrl(proxyUrl, proxyUsername, proxyPassword) {
|
|
|
1663
2007
|
* @return ProxyConfiguration
|
|
1664
2008
|
*/
|
|
1665
2009
|
function getHttpProxyConfiguration(requestUrl) {
|
|
1666
|
-
var proxyUrl = exports.getVariable('Agent.ProxyUrl');
|
|
2010
|
+
var proxyUrl = (0, exports.getVariable)('Agent.ProxyUrl');
|
|
1667
2011
|
if (proxyUrl && proxyUrl.length > 0) {
|
|
1668
|
-
var proxyUsername = exports.getVariable('Agent.ProxyUsername');
|
|
1669
|
-
var proxyPassword = exports.getVariable('Agent.ProxyPassword');
|
|
1670
|
-
var proxyBypassHosts = JSON.parse(exports.getVariable('Agent.ProxyBypassList') || '[]');
|
|
2012
|
+
var proxyUsername = (0, exports.getVariable)('Agent.ProxyUsername');
|
|
2013
|
+
var proxyPassword = (0, exports.getVariable)('Agent.ProxyPassword');
|
|
2014
|
+
var proxyBypassHosts = JSON.parse((0, exports.getVariable)('Agent.ProxyBypassList') || '[]');
|
|
1671
2015
|
var bypass_1 = false;
|
|
1672
2016
|
if (requestUrl) {
|
|
1673
2017
|
proxyBypassHosts.forEach(function (bypassHost) {
|
|
@@ -1701,16 +2045,16 @@ exports.getHttpProxyConfiguration = getHttpProxyConfiguration;
|
|
|
1701
2045
|
* @return CertConfiguration
|
|
1702
2046
|
*/
|
|
1703
2047
|
function getHttpCertConfiguration() {
|
|
1704
|
-
var ca = exports.getVariable('Agent.CAInfo');
|
|
1705
|
-
var clientCert = exports.getVariable('Agent.ClientCert');
|
|
2048
|
+
var ca = (0, exports.getVariable)('Agent.CAInfo');
|
|
2049
|
+
var clientCert = (0, exports.getVariable)('Agent.ClientCert');
|
|
1706
2050
|
if (ca || clientCert) {
|
|
1707
2051
|
var certConfig = {};
|
|
1708
2052
|
certConfig.caFile = ca;
|
|
1709
2053
|
certConfig.certFile = clientCert;
|
|
1710
2054
|
if (clientCert) {
|
|
1711
|
-
var clientCertKey = exports.getVariable('Agent.ClientCertKey');
|
|
1712
|
-
var clientCertArchive = exports.getVariable('Agent.ClientCertArchive');
|
|
1713
|
-
var clientCertPassword = exports.getVariable('Agent.ClientCertPassword');
|
|
2055
|
+
var clientCertKey = (0, exports.getVariable)('Agent.ClientCertKey');
|
|
2056
|
+
var clientCertArchive = (0, exports.getVariable)('Agent.ClientCertArchive');
|
|
2057
|
+
var clientCertPassword = (0, exports.getVariable)('Agent.ClientCertPassword');
|
|
1714
2058
|
certConfig.keyFile = clientCertKey;
|
|
1715
2059
|
certConfig.certArchiveFile = clientCertArchive;
|
|
1716
2060
|
certConfig.passphrase = clientCertPassword;
|
|
@@ -1754,7 +2098,7 @@ var TestPublisher = /** @class */ (function () {
|
|
|
1754
2098
|
properties['resultFiles'] = Array.isArray(resultFiles) ? resultFiles.join() : resultFiles;
|
|
1755
2099
|
}
|
|
1756
2100
|
properties['testRunSystem'] = testRunSystem;
|
|
1757
|
-
exports.command('results.publish', properties, '');
|
|
2101
|
+
(0, exports.command)('results.publish', properties, '');
|
|
1758
2102
|
};
|
|
1759
2103
|
return TestPublisher;
|
|
1760
2104
|
}());
|
|
@@ -1779,7 +2123,7 @@ var CodeCoveragePublisher = /** @class */ (function () {
|
|
|
1779
2123
|
if (additionalCodeCoverageFiles) {
|
|
1780
2124
|
properties['additionalcodecoveragefiles'] = Array.isArray(additionalCodeCoverageFiles) ? additionalCodeCoverageFiles.join() : additionalCodeCoverageFiles;
|
|
1781
2125
|
}
|
|
1782
|
-
exports.command('codecoverage.publish', properties, "");
|
|
2126
|
+
(0, exports.command)('codecoverage.publish', properties, "");
|
|
1783
2127
|
};
|
|
1784
2128
|
return CodeCoveragePublisher;
|
|
1785
2129
|
}());
|
|
@@ -1795,7 +2139,7 @@ var CodeCoverageEnabler = /** @class */ (function () {
|
|
|
1795
2139
|
CodeCoverageEnabler.prototype.enableCodeCoverage = function (buildProps) {
|
|
1796
2140
|
buildProps['buildtool'] = this.buildTool;
|
|
1797
2141
|
buildProps['codecoveragetool'] = this.ccTool;
|
|
1798
|
-
exports.command('codecoverage.enable', buildProps, "");
|
|
2142
|
+
(0, exports.command)('codecoverage.enable', buildProps, "");
|
|
1799
2143
|
};
|
|
1800
2144
|
return CodeCoverageEnabler;
|
|
1801
2145
|
}());
|
|
@@ -1813,7 +2157,7 @@ exports.CodeCoverageEnabler = CodeCoverageEnabler;
|
|
|
1813
2157
|
* @returns void
|
|
1814
2158
|
*/
|
|
1815
2159
|
function uploadFile(path) {
|
|
1816
|
-
exports.command("task.uploadfile", null, path);
|
|
2160
|
+
(0, exports.command)("task.uploadfile", null, path);
|
|
1817
2161
|
}
|
|
1818
2162
|
exports.uploadFile = uploadFile;
|
|
1819
2163
|
/**
|
|
@@ -1826,7 +2170,7 @@ exports.uploadFile = uploadFile;
|
|
|
1826
2170
|
*/
|
|
1827
2171
|
function prependPath(path) {
|
|
1828
2172
|
assertAgent("2.115.0");
|
|
1829
|
-
exports.command("task.prependpath", null, path);
|
|
2173
|
+
(0, exports.command)("task.prependpath", null, path);
|
|
1830
2174
|
}
|
|
1831
2175
|
exports.prependPath = prependPath;
|
|
1832
2176
|
/**
|
|
@@ -1838,7 +2182,7 @@ exports.prependPath = prependPath;
|
|
|
1838
2182
|
* @returns void
|
|
1839
2183
|
*/
|
|
1840
2184
|
function uploadSummary(path) {
|
|
1841
|
-
exports.command("task.uploadsummary", null, path);
|
|
2185
|
+
(0, exports.command)("task.uploadsummary", null, path);
|
|
1842
2186
|
}
|
|
1843
2187
|
exports.uploadSummary = uploadSummary;
|
|
1844
2188
|
/**
|
|
@@ -1852,7 +2196,7 @@ exports.uploadSummary = uploadSummary;
|
|
|
1852
2196
|
* @returns void
|
|
1853
2197
|
*/
|
|
1854
2198
|
function addAttachment(type, name, path) {
|
|
1855
|
-
exports.command("task.addattachment", { "type": type, "name": name }, path);
|
|
2199
|
+
(0, exports.command)("task.addattachment", { "type": type, "name": name }, path);
|
|
1856
2200
|
}
|
|
1857
2201
|
exports.addAttachment = addAttachment;
|
|
1858
2202
|
/**
|
|
@@ -1867,7 +2211,7 @@ exports.addAttachment = addAttachment;
|
|
|
1867
2211
|
* @returns void
|
|
1868
2212
|
*/
|
|
1869
2213
|
function setEndpoint(id, field, key, value) {
|
|
1870
|
-
exports.command("task.setendpoint", { "id": id, "field": FieldType[field].toLowerCase(), "key": key }, value);
|
|
2214
|
+
(0, exports.command)("task.setendpoint", { "id": id, "field": FieldType[field].toLowerCase(), "key": key }, value);
|
|
1871
2215
|
}
|
|
1872
2216
|
exports.setEndpoint = setEndpoint;
|
|
1873
2217
|
/**
|
|
@@ -1878,7 +2222,7 @@ exports.setEndpoint = setEndpoint;
|
|
|
1878
2222
|
* @returns void
|
|
1879
2223
|
*/
|
|
1880
2224
|
function setProgress(percent, currentOperation) {
|
|
1881
|
-
exports.command("task.setprogress", { "value": ""
|
|
2225
|
+
(0, exports.command)("task.setprogress", { "value": "".concat(percent) }, currentOperation);
|
|
1882
2226
|
}
|
|
1883
2227
|
exports.setProgress = setProgress;
|
|
1884
2228
|
/**
|
|
@@ -1910,7 +2254,7 @@ function logDetail(id, message, parentId, recordType, recordName, order, startTi
|
|
|
1910
2254
|
"state": state ? TaskState[state] : undefined,
|
|
1911
2255
|
"result": result ? TaskResult[result] : undefined
|
|
1912
2256
|
};
|
|
1913
|
-
exports.command("task.logdetail", properties, message);
|
|
2257
|
+
(0, exports.command)("task.logdetail", properties, message);
|
|
1914
2258
|
}
|
|
1915
2259
|
exports.logDetail = logDetail;
|
|
1916
2260
|
/**
|
|
@@ -1932,7 +2276,7 @@ function logIssue(type, message, sourcePath, lineNumber, columnNumber, errorCode
|
|
|
1932
2276
|
"linenumber": lineNumber ? lineNumber.toString() : undefined,
|
|
1933
2277
|
"columnnumber": columnNumber ? columnNumber.toString() : undefined,
|
|
1934
2278
|
};
|
|
1935
|
-
exports.command("task.logissue", properties, message);
|
|
2279
|
+
(0, exports.command)("task.logissue", properties, message);
|
|
1936
2280
|
}
|
|
1937
2281
|
exports.logIssue = logIssue;
|
|
1938
2282
|
//-----------------------------------------------------
|
|
@@ -1950,7 +2294,7 @@ exports.logIssue = logIssue;
|
|
|
1950
2294
|
* @returns void
|
|
1951
2295
|
*/
|
|
1952
2296
|
function uploadArtifact(containerFolder, path, name) {
|
|
1953
|
-
exports.command("artifact.upload", { "containerfolder": containerFolder, "artifactname": name }, path);
|
|
2297
|
+
(0, exports.command)("artifact.upload", { "containerfolder": containerFolder, "artifactname": name }, path);
|
|
1954
2298
|
}
|
|
1955
2299
|
exports.uploadArtifact = uploadArtifact;
|
|
1956
2300
|
/**
|
|
@@ -1965,7 +2309,7 @@ exports.uploadArtifact = uploadArtifact;
|
|
|
1965
2309
|
* @returns void
|
|
1966
2310
|
*/
|
|
1967
2311
|
function associateArtifact(name, path, artifactType) {
|
|
1968
|
-
exports.command("artifact.associate", { "type": ArtifactType[artifactType].toLowerCase(), "artifactname": name }, path);
|
|
2312
|
+
(0, exports.command)("artifact.associate", { "type": ArtifactType[artifactType].toLowerCase(), "artifactname": name }, path);
|
|
1969
2313
|
}
|
|
1970
2314
|
exports.associateArtifact = associateArtifact;
|
|
1971
2315
|
//-----------------------------------------------------
|
|
@@ -1978,7 +2322,7 @@ exports.associateArtifact = associateArtifact;
|
|
|
1978
2322
|
* @returns void
|
|
1979
2323
|
*/
|
|
1980
2324
|
function uploadBuildLog(path) {
|
|
1981
|
-
exports.command("build.uploadlog", null, path);
|
|
2325
|
+
(0, exports.command)("build.uploadlog", null, path);
|
|
1982
2326
|
}
|
|
1983
2327
|
exports.uploadBuildLog = uploadBuildLog;
|
|
1984
2328
|
/**
|
|
@@ -1988,7 +2332,7 @@ exports.uploadBuildLog = uploadBuildLog;
|
|
|
1988
2332
|
* @returns void
|
|
1989
2333
|
*/
|
|
1990
2334
|
function updateBuildNumber(value) {
|
|
1991
|
-
exports.command("build.updatebuildnumber", null, value);
|
|
2335
|
+
(0, exports.command)("build.updatebuildnumber", null, value);
|
|
1992
2336
|
}
|
|
1993
2337
|
exports.updateBuildNumber = updateBuildNumber;
|
|
1994
2338
|
/**
|
|
@@ -1998,7 +2342,7 @@ exports.updateBuildNumber = updateBuildNumber;
|
|
|
1998
2342
|
* @returns void
|
|
1999
2343
|
*/
|
|
2000
2344
|
function addBuildTag(value) {
|
|
2001
|
-
exports.command("build.addbuildtag", null, value);
|
|
2345
|
+
(0, exports.command)("build.addbuildtag", null, value);
|
|
2002
2346
|
}
|
|
2003
2347
|
exports.addBuildTag = addBuildTag;
|
|
2004
2348
|
//-----------------------------------------------------
|
|
@@ -2012,7 +2356,7 @@ exports.addBuildTag = addBuildTag;
|
|
|
2012
2356
|
*/
|
|
2013
2357
|
function updateReleaseName(name) {
|
|
2014
2358
|
assertAgent("2.132.0");
|
|
2015
|
-
exports.command("release.updatereleasename", null, name);
|
|
2359
|
+
(0, exports.command)("release.updatereleasename", null, name);
|
|
2016
2360
|
}
|
|
2017
2361
|
exports.updateReleaseName = updateReleaseName;
|
|
2018
2362
|
//-----------------------------------------------------
|
|
@@ -2026,7 +2370,7 @@ exports.ToolRunner = trm.ToolRunner;
|
|
|
2026
2370
|
//-----------------------------------------------------
|
|
2027
2371
|
// async await needs generators in node 4.x+
|
|
2028
2372
|
if (semver.lt(process.versions.node, '4.2.0')) {
|
|
2029
|
-
exports.warning('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later');
|
|
2373
|
+
(0, exports.warning)('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later', exports.IssueSource.TaskInternal);
|
|
2030
2374
|
}
|
|
2031
2375
|
//-------------------------------------------------------------------
|
|
2032
2376
|
// Populate the vault with sensitive data. Inputs and Endpoints
|