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