azure-pipelines-task-lib 5.0.0-preview.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,210 @@ 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 preparedPaths = [];
933
+ try {
934
+ var _loop_1 = function () {
935
+ var pathEntry = resolve(paths.shift());
936
+ if (pathEntry === null || pathEntry === void 0 ? void 0 : pathEntry.includes('*')) {
937
+ paths.push.apply(paths, findMatch(path.dirname(pathEntry), [path.basename(pathEntry)]));
938
+ return "continue";
939
+ }
940
+ if (fs.lstatSync(pathEntry).isDirectory()) {
941
+ preparedPaths.push.apply(preparedPaths, fs.readdirSync(pathEntry).map(function (file) { return path.join(pathEntry, file); }));
942
+ }
943
+ else {
944
+ preparedPaths.push(pathEntry);
945
+ }
946
+ };
947
+ while (paths.length > 0) {
948
+ _loop_1();
949
+ }
950
+ var entries = [];
951
+ var _loop_2 = function () {
952
+ var entry = preparedPaths.shift();
953
+ var entrybasename = path.basename(entry);
954
+ if (entry === null || entry === void 0 ? void 0 : entry.includes('*')) {
955
+ preparedPaths.push.apply(preparedPaths, findMatch(path.dirname(entry), [entrybasename]));
956
+ return "continue";
957
+ }
958
+ if (!includeHidden && entrybasename.startsWith('.') && entrybasename !== '.' && entrybasename !== '..') {
959
+ return "continue";
960
+ }
961
+ if (fs.lstatSync(entry).isDirectory() && isRecursive) {
962
+ preparedPaths.push.apply(preparedPaths, fs.readdirSync(entry).map(function (x) { return path.join(entry, x); }));
963
+ }
964
+ else {
965
+ entries.push(entry);
966
+ }
967
+ };
968
+ while (preparedPaths.length > 0) {
969
+ _loop_2();
970
+ }
971
+ return entries;
972
+ }
973
+ catch (error) {
974
+ if (error.code === 'ENOENT') {
975
+ throw new Error((0, exports.loc)('LIB_PathNotFound', 'ls', error.message));
976
+ }
977
+ else {
978
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'ls', error));
979
+ }
772
980
  }
773
981
  }
774
982
  exports.ls = ls;
775
983
  /**
776
984
  * 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) {
985
+ * @param {string} sourceOrOptions - Either the source path or an option string '-r', '-f' , '-n' or '-rfn' for recursive, force and no-clobber.
986
+ * @param {string} destinationOrSource - Destination path or the source path.
987
+ * @param {string} [optionsOrDestination] - Options string or the destination path.
988
+ * @param {boolean} [continueOnError=false] - Optional. Whether to continue on error.
989
+ * @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.
990
+ * @returns {void}
991
+ */
992
+ function cp(sourceOrOptions, destinationOrSource, optionsOrDestination, continueOnError, retryCount) {
993
+ if (continueOnError === void 0) { continueOnError = false; }
785
994
  if (retryCount === void 0) { retryCount = 0; }
786
- while (retryCount >= 0) {
787
- try {
788
- if (options) {
789
- shell.cp(options, source, dest);
790
- }
791
- else {
792
- shell.cp(source, dest);
793
- }
794
- _checkShell('cp', false);
795
- break;
995
+ retry(function () {
996
+ var recursive = false;
997
+ var force = true;
998
+ var source = String(sourceOrOptions);
999
+ var destination = destinationOrSource;
1000
+ var options = '';
1001
+ if (typeof sourceOrOptions === 'string' && sourceOrOptions.startsWith('-')) {
1002
+ options = sourceOrOptions.toLowerCase();
1003
+ recursive = options.includes('r');
1004
+ force = !options.includes('n');
1005
+ source = destinationOrSource;
1006
+ destination = String(optionsOrDestination);
1007
+ }
1008
+ else if (typeof optionsOrDestination === 'string' && optionsOrDestination && optionsOrDestination.startsWith('-')) {
1009
+ options = optionsOrDestination.toLowerCase();
1010
+ recursive = options.includes('r');
1011
+ force = !options.includes('n');
1012
+ source = String(sourceOrOptions);
1013
+ destination = destinationOrSource;
1014
+ }
1015
+ if (!fs.existsSync(destination) && !force) {
1016
+ throw new Error((0, exports.loc)('LIB_PathNotFound', 'cp', destination));
1017
+ }
1018
+ var lstatSource = fs.lstatSync(source);
1019
+ if (!force && fs.existsSync(destination)) {
1020
+ return;
796
1021
  }
797
- catch (e) {
798
- if (retryCount <= 0) {
799
- if (continueOnError) {
800
- exports.warning(e);
801
- break;
1022
+ try {
1023
+ if (lstatSource.isFile()) {
1024
+ if (fs.existsSync(destination) && fs.lstatSync(destination).isDirectory()) {
1025
+ destination = path.join(destination, path.basename(source));
1026
+ }
1027
+ if (force) {
1028
+ fs.copyFileSync(source, destination);
802
1029
  }
803
1030
  else {
804
- throw e;
1031
+ fs.copyFileSync(source, destination, fs.constants.COPYFILE_EXCL);
805
1032
  }
806
1033
  }
807
1034
  else {
808
- console.log(exports.loc('LIB_CopyFileFailed', retryCount));
809
- retryCount--;
1035
+ fs.cpSync(source, path.join(destination, path.basename(source)), { recursive: recursive, force: force });
810
1036
  }
811
1037
  }
812
- }
1038
+ catch (error) {
1039
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'cp', error));
1040
+ }
1041
+ }, [], { retryCount: retryCount, continueOnError: continueOnError });
813
1042
  }
814
1043
  exports.cp = cp;
815
1044
  /**
816
1045
  * Moves a path.
817
1046
  *
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
1047
+ * @param {string} source - Source path.
1048
+ * @param {string} dest - Destination path.
1049
+ * @param {MoveOptionsVariants} [options] - Option string -f or -n for force and no clobber.
1050
+ * @param {boolean} [continueOnError] - Optional. Whether to continue on error.
1051
+ * @returns {void}
822
1052
  */
823
1053
  function mv(source, dest, options, continueOnError) {
824
- if (options) {
825
- shell.mv(options, source, dest);
1054
+ var force = false;
1055
+ if (options && typeof options === 'string' && options.startsWith('-')) {
1056
+ var lowercasedOptions = String(options).toLowerCase();
1057
+ force = lowercasedOptions.includes('f') && !lowercasedOptions.includes('n');
1058
+ }
1059
+ var sourceExists = fs.existsSync(source);
1060
+ var destExists = fs.existsSync(dest);
1061
+ var sources = [];
1062
+ try {
1063
+ if (!sourceExists) {
1064
+ if (source.includes('*')) {
1065
+ sources.push.apply(sources, findMatch(path.resolve(path.dirname(source)), [path.basename(source)]));
1066
+ }
1067
+ else {
1068
+ throw new Error((0, exports.loc)('LIB_PathNotFound', 'mv', source));
1069
+ }
1070
+ }
1071
+ else {
1072
+ sources.push(source);
1073
+ }
1074
+ if (destExists && !force) {
1075
+ throw new Error("File already exists at ".concat(dest));
1076
+ }
1077
+ for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
1078
+ var source_1 = sources_1[_i];
1079
+ fs.renameSync(source_1, dest);
1080
+ }
826
1081
  }
827
- else {
828
- shell.mv(source, dest);
1082
+ catch (error) {
1083
+ (0, exports.debug)('mv failed');
1084
+ var errMsg = (0, exports.loc)('LIB_OperationFailed', 'mv', error);
1085
+ (0, exports.debug)(errMsg);
1086
+ if (!continueOnError) {
1087
+ throw new Error(errMsg);
1088
+ }
829
1089
  }
830
- _checkShell('mv', continueOnError);
831
1090
  }
832
1091
  exports.mv = mv;
833
1092
  /**
@@ -847,7 +1106,7 @@ function retry(func, args, retryOptions) {
847
1106
  catch (e) {
848
1107
  if (retryOptions.retryCount <= 0) {
849
1108
  if (retryOptions.continueOnError) {
850
- exports.warning(e);
1109
+ (0, exports.warning)(e, exports.IssueSource.TaskInternal);
851
1110
  break;
852
1111
  }
853
1112
  else {
@@ -855,7 +1114,7 @@ function retry(func, args, retryOptions) {
855
1114
  }
856
1115
  }
857
1116
  else {
858
- exports.debug("Attempt to execute function \"" + (func === null || func === void 0 ? void 0 : func.name) + "\" failed, retries left: " + retryOptions.retryCount);
1117
+ (0, exports.debug)("Attempt to execute function \"".concat(func === null || func === void 0 ? void 0 : func.name, "\" failed, retries left: ").concat(retryOptions.retryCount));
859
1118
  retryOptions.retryCount--;
860
1119
  }
861
1120
  }
@@ -883,7 +1142,7 @@ function _getStats(path, followSymbolicLink, allowBrokenSymbolicLinks) {
883
1142
  if (err.code == 'ENOENT' && allowBrokenSymbolicLinks) {
884
1143
  // fallback to lstat (broken symlinks allowed)
885
1144
  stats = fs.lstatSync(path);
886
- exports.debug(" " + path + " (broken symlink)");
1145
+ (0, exports.debug)(" ".concat(path, " (broken symlink)"));
887
1146
  }
888
1147
  else {
889
1148
  throw err;
@@ -905,14 +1164,14 @@ function _getStats(path, followSymbolicLink, allowBrokenSymbolicLinks) {
905
1164
  */
906
1165
  function find(findPath, options) {
907
1166
  if (!findPath) {
908
- exports.debug('no path specified');
1167
+ (0, exports.debug)('no path specified');
909
1168
  return [];
910
1169
  }
911
1170
  // normalize the path, otherwise the first result is inconsistently formatted from the rest of the results
912
1171
  // because path.join() performs normalization.
913
1172
  findPath = path.normalize(findPath);
914
1173
  // debug trace the parameters
915
- exports.debug("findPath: '" + findPath + "'");
1174
+ (0, exports.debug)("findPath: '".concat(findPath, "'"));
916
1175
  options = options || _getDefaultFindOptions();
917
1176
  _debugFindOptions(options);
918
1177
  // return empty if not exists
@@ -921,7 +1180,7 @@ function find(findPath, options) {
921
1180
  }
922
1181
  catch (err) {
923
1182
  if (err.code == 'ENOENT') {
924
- exports.debug('0 results');
1183
+ (0, exports.debug)('0 results');
925
1184
  return [];
926
1185
  }
927
1186
  throw err;
@@ -931,7 +1190,7 @@ function find(findPath, options) {
931
1190
  // push the first item
932
1191
  var stack = [new _FindItem(findPath, 1)];
933
1192
  var traversalChain = []; // used to detect cycles
934
- var _loop_1 = function () {
1193
+ var _loop_3 = function () {
935
1194
  // pop the next item and push to the result array
936
1195
  var item = stack.pop(); // non-null because `stack.length` was truthy
937
1196
  var stats_2 = void 0;
@@ -947,7 +1206,7 @@ function find(findPath, options) {
947
1206
  }
948
1207
  catch (err) {
949
1208
  if (err.code == 'ENOENT' && options.skipMissingFiles) {
950
- exports.warning("No such file or directory: \"" + item.path + "\" - skipping.");
1209
+ (0, exports.warning)("No such file or directory: \"".concat(item.path, "\" - skipping."), exports.IssueSource.TaskInternal);
951
1210
  return "continue";
952
1211
  }
953
1212
  throw err;
@@ -955,7 +1214,7 @@ function find(findPath, options) {
955
1214
  result.push(item.path);
956
1215
  // note, isDirectory() returns false for the lstat of a symlink
957
1216
  if (stats_2.isDirectory()) {
958
- exports.debug(" " + item.path + " (directory)");
1217
+ (0, exports.debug)(" ".concat(item.path, " (directory)"));
959
1218
  if (options.followSymbolicLinks) {
960
1219
  // get the realpath
961
1220
  var realPath_1;
@@ -972,7 +1231,7 @@ function find(findPath, options) {
972
1231
  }
973
1232
  // test for a cycle
974
1233
  if (traversalChain.some(function (x) { return x == realPath_1; })) {
975
- exports.debug(' cycle detected');
1234
+ (0, exports.debug)(' cycle detected');
976
1235
  return "continue";
977
1236
  }
978
1237
  // update the traversal chain
@@ -987,17 +1246,17 @@ function find(findPath, options) {
987
1246
  }
988
1247
  }
989
1248
  else {
990
- exports.debug(" " + item.path + " (file)");
1249
+ (0, exports.debug)(" ".concat(item.path, " (file)"));
991
1250
  }
992
1251
  };
993
1252
  while (stack.length) {
994
- _loop_1();
1253
+ _loop_3();
995
1254
  }
996
- exports.debug(result.length + " results");
1255
+ (0, exports.debug)("".concat(result.length, " results"));
997
1256
  return result;
998
1257
  }
999
1258
  catch (err) {
1000
- throw new Error(exports.loc('LIB_OperationFailed', 'find', err.message));
1259
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'find', err.message));
1001
1260
  }
1002
1261
  }
1003
1262
  exports.find = find;
@@ -1009,10 +1268,10 @@ var _FindItem = /** @class */ (function () {
1009
1268
  return _FindItem;
1010
1269
  }());
1011
1270
  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 + "'");
1271
+ (0, exports.debug)("findOptions.allowBrokenSymbolicLinks: '".concat(options.allowBrokenSymbolicLinks, "'"));
1272
+ (0, exports.debug)("findOptions.followSpecifiedSymbolicLink: '".concat(options.followSpecifiedSymbolicLink, "'"));
1273
+ (0, exports.debug)("findOptions.followSymbolicLinks: '".concat(options.followSymbolicLinks, "'"));
1274
+ (0, exports.debug)("findOptions.skipMissingFiles: '".concat(options.skipMissingFiles, "'"));
1016
1275
  }
1017
1276
  function _getDefaultFindOptions() {
1018
1277
  return {
@@ -1036,10 +1295,10 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
1036
1295
  if (!pattern) {
1037
1296
  throw new Error('pattern parameter cannot be empty');
1038
1297
  }
1039
- exports.debug("legacyFindFiles rootDirectory: '" + rootDirectory + "'");
1040
- exports.debug("pattern: '" + pattern + "'");
1041
- exports.debug("includeFiles: '" + includeFiles + "'");
1042
- exports.debug("includeDirectories: '" + includeDirectories + "'");
1298
+ (0, exports.debug)("legacyFindFiles rootDirectory: '".concat(rootDirectory, "'"));
1299
+ (0, exports.debug)("pattern: '".concat(pattern, "'"));
1300
+ (0, exports.debug)("includeFiles: '".concat(includeFiles, "'"));
1301
+ (0, exports.debug)("includeDirectories: '".concat(includeDirectories, "'"));
1043
1302
  if (!includeFiles && !includeDirectories) {
1044
1303
  includeFiles = true;
1045
1304
  }
@@ -1070,7 +1329,7 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
1070
1329
  }
1071
1330
  // validate pattern does not end with a slash
1072
1331
  if (im._endsWith(pat, '/') || (process.platform == 'win32' && im._endsWith(pat, '\\'))) {
1073
- throw new Error(exports.loc('LIB_InvalidPattern', pat));
1332
+ throw new Error((0, exports.loc)('LIB_InvalidPattern', pat));
1074
1333
  }
1075
1334
  // root the pattern
1076
1335
  if (rootDirectory && !path.isAbsolute(pat)) {
@@ -1092,29 +1351,29 @@ function legacyFindFiles(rootDirectory, pattern, includeFiles, includeDirectorie
1092
1351
  // find and apply patterns
1093
1352
  var count = 0;
1094
1353
  var result = _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, !!includeFiles, !!includeDirectories);
1095
- exports.debug('all matches:');
1354
+ (0, exports.debug)('all matches:');
1096
1355
  for (var _b = 0, result_1 = result; _b < result_1.length; _b++) {
1097
1356
  var resultItem = result_1[_b];
1098
- exports.debug(' ' + resultItem);
1357
+ (0, exports.debug)(' ' + resultItem);
1099
1358
  }
1100
- exports.debug('total matched: ' + result.length);
1359
+ (0, exports.debug)('total matched: ' + result.length);
1101
1360
  return result;
1102
1361
  }
1103
1362
  exports.legacyFindFiles = legacyFindFiles;
1104
1363
  function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, includeFiles, includeDirectories) {
1105
- exports.debug('getMatchingItems()');
1364
+ (0, exports.debug)('getMatchingItems()');
1106
1365
  for (var _i = 0, includePatterns_1 = includePatterns; _i < includePatterns_1.length; _i++) {
1107
1366
  var pattern = includePatterns_1[_i];
1108
- exports.debug("includePattern: '" + pattern + "'");
1367
+ (0, exports.debug)("includePattern: '".concat(pattern, "'"));
1109
1368
  }
1110
1369
  for (var _a = 0, excludePatterns_1 = excludePatterns; _a < excludePatterns_1.length; _a++) {
1111
1370
  var pattern = excludePatterns_1[_a];
1112
- exports.debug("excludePattern: " + pattern);
1371
+ (0, exports.debug)("excludePattern: ".concat(pattern));
1113
1372
  }
1114
- exports.debug('includeFiles: ' + includeFiles);
1115
- exports.debug('includeDirectories: ' + includeDirectories);
1373
+ (0, exports.debug)('includeFiles: ' + includeFiles);
1374
+ (0, exports.debug)('includeDirectories: ' + includeDirectories);
1116
1375
  var allFiles = {};
1117
- var _loop_2 = function (pattern) {
1376
+ var _loop_4 = function (pattern) {
1118
1377
  // determine the directory to search
1119
1378
  //
1120
1379
  // note, getDirectoryName removes redundant path separators
@@ -1155,7 +1414,7 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
1155
1414
  var normalizedPath = process.platform == 'win32' ? item.replace(/\\/g, '/') : item; // normalize separators
1156
1415
  // **/times/** will not match C:/fun/times because there isn't a trailing slash
1157
1416
  // so try both if including directories
1158
- var alternatePath = normalizedPath + "/"; // potential bug: it looks like this will result in a false
1417
+ var alternatePath = "".concat(normalizedPath, "/"); // potential bug: it looks like this will result in a false
1159
1418
  // positive if the item is a regular file and not a directory
1160
1419
  var isMatch = false;
1161
1420
  if (patternRegex.test(normalizedPath) || (includeDirectories && patternRegex.test(alternatePath))) {
@@ -1176,36 +1435,37 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
1176
1435
  };
1177
1436
  for (var _b = 0, includePatterns_2 = includePatterns; _b < includePatterns_2.length; _b++) {
1178
1437
  var pattern = includePatterns_2[_b];
1179
- _loop_2(pattern);
1438
+ _loop_4(pattern);
1180
1439
  }
1181
1440
  return Object.keys(allFiles).sort();
1182
1441
  }
1183
1442
  /**
1184
1443
  * Remove a path recursively with force
1185
1444
  *
1186
- * @param inputPath path to remove
1187
- * @throws when the file or directory exists but could not be deleted.
1445
+ * @param {string} inputPath - Path to remove
1446
+ * @return {void}
1447
+ * @throws When the file or directory exists but could not be deleted.
1188
1448
  */
1189
1449
  function rmRF(inputPath) {
1190
- exports.debug('rm -rf ' + inputPath);
1450
+ (0, exports.debug)('rm -rf ' + inputPath);
1191
1451
  if (getPlatform() == Platform.Windows) {
1192
1452
  // Node doesn't provide a delete operation, only an unlink function. This means that if the file is being used by another
1193
1453
  // program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
1194
1454
  try {
1195
1455
  if (fs.statSync(inputPath).isDirectory()) {
1196
- exports.debug('removing directory ' + inputPath);
1197
- childProcess.execSync("rd /s /q \"" + inputPath + "\"");
1456
+ (0, exports.debug)('removing directory ' + inputPath);
1457
+ childProcess.execFileSync("cmd.exe", ["/c", "rd", "/s", "/q", inputPath]);
1198
1458
  }
1199
1459
  else {
1200
- exports.debug('removing file ' + inputPath);
1201
- childProcess.execSync("del /f /a \"" + inputPath + "\"");
1460
+ (0, exports.debug)('removing file ' + inputPath);
1461
+ childProcess.execFileSync("cmd.exe", ["/c", "del", "/f", "/a", inputPath]);
1202
1462
  }
1203
1463
  }
1204
1464
  catch (err) {
1205
1465
  // if you try to delete a file that doesn't exist, desired result is achieved
1206
1466
  // other errors are valid
1207
1467
  if (err.code != 'ENOENT') {
1208
- throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
1468
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
1209
1469
  }
1210
1470
  }
1211
1471
  // Shelling out fails to remove a symlink folder with missing source, this unlink catches that
@@ -1216,7 +1476,7 @@ function rmRF(inputPath) {
1216
1476
  // if you try to delete a file that doesn't exist, desired result is achieved
1217
1477
  // other errors are valid
1218
1478
  if (err.code != 'ENOENT') {
1219
- throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
1479
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
1220
1480
  }
1221
1481
  }
1222
1482
  }
@@ -1225,7 +1485,17 @@ function rmRF(inputPath) {
1225
1485
  // with missing targets are not handled correctly by "rm('-rf', path)"
1226
1486
  var lstats = void 0;
1227
1487
  try {
1228
- lstats = fs.lstatSync(inputPath);
1488
+ if (inputPath.includes('*')) {
1489
+ var entries = findMatch(path.dirname(inputPath), [path.basename(inputPath)]);
1490
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
1491
+ var entry = entries_1[_i];
1492
+ fs.rmSync(entry, { recursive: true, force: true });
1493
+ }
1494
+ return;
1495
+ }
1496
+ else {
1497
+ lstats = fs.lstatSync(inputPath);
1498
+ }
1229
1499
  }
1230
1500
  catch (err) {
1231
1501
  // if you try to delete a file that doesn't exist, desired result is achieved
@@ -1233,23 +1503,38 @@ function rmRF(inputPath) {
1233
1503
  if (err.code == 'ENOENT') {
1234
1504
  return;
1235
1505
  }
1236
- throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
1506
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
1237
1507
  }
1238
1508
  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));
1509
+ (0, exports.debug)('removing directory');
1510
+ try {
1511
+ fs.rmSync(inputPath, { recursive: true, force: true });
1512
+ }
1513
+ catch (errMsg) {
1514
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', errMsg));
1244
1515
  }
1245
1516
  return;
1246
1517
  }
1247
- exports.debug('removing file');
1518
+ else if (lstats.isSymbolicLink()) {
1519
+ (0, exports.debug)('removing symbolic link');
1520
+ try {
1521
+ fs.unlinkSync(inputPath);
1522
+ }
1523
+ catch (errMsg) {
1524
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', errMsg));
1525
+ }
1526
+ return;
1527
+ }
1528
+ (0, exports.debug)('removing file');
1248
1529
  try {
1249
- fs.unlinkSync(inputPath);
1530
+ var entries = findMatch(path.dirname(inputPath), [path.basename(inputPath)]);
1531
+ for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
1532
+ var entry = entries_2[_a];
1533
+ fs.rmSync(entry, { recursive: true, force: true });
1534
+ }
1250
1535
  }
1251
1536
  catch (err) {
1252
- throw new Error(exports.loc('LIB_OperationFailed', 'rmRF', err.message));
1537
+ throw new Error((0, exports.loc)('LIB_OperationFailed', 'rmRF', err.message));
1253
1538
  }
1254
1539
  }
1255
1540
  }
@@ -1264,11 +1549,32 @@ exports.rmRF = rmRF;
1264
1549
  * @param options optional exec options. See IExecOptions
1265
1550
  * @returns number
1266
1551
  */
1552
+ function execAsync(tool, args, options) {
1553
+ var tr = this.tool(tool);
1554
+ if (args) {
1555
+ if (args instanceof Array) {
1556
+ tr.arg(args);
1557
+ }
1558
+ else if (typeof (args) === 'string') {
1559
+ tr.line(args);
1560
+ }
1561
+ }
1562
+ return tr.execAsync(options);
1563
+ }
1564
+ exports.execAsync = execAsync;
1565
+ /**
1566
+ * Exec a tool. Convenience wrapper over ToolRunner to exec with args in one call.
1567
+ * Output will be streamed to the live console.
1568
+ * Returns promise with return code
1569
+ *
1570
+ * @deprecated Use the {@link execAsync} method that returns a native Javascript Promise instead
1571
+ * @param tool path to tool to exec
1572
+ * @param args an arg string or array of args
1573
+ * @param options optional exec options. See IExecOptions
1574
+ * @returns number
1575
+ */
1267
1576
  function exec(tool, args, options) {
1268
1577
  var tr = this.tool(tool);
1269
- tr.on('debug', function (data) {
1270
- exports.debug(data);
1271
- });
1272
1578
  if (args) {
1273
1579
  if (args instanceof Array) {
1274
1580
  tr.arg(args);
@@ -1293,9 +1599,6 @@ exports.exec = exec;
1293
1599
  */
1294
1600
  function execSync(tool, args, options) {
1295
1601
  var tr = this.tool(tool);
1296
- tr.on('debug', function (data) {
1297
- exports.debug(data);
1298
- });
1299
1602
  if (args) {
1300
1603
  if (args instanceof Array) {
1301
1604
  tr.arg(args);
@@ -1316,7 +1619,7 @@ exports.execSync = execSync;
1316
1619
  function tool(tool) {
1317
1620
  var tr = new trm.ToolRunner(tool);
1318
1621
  tr.on('debug', function (message) {
1319
- exports.debug(message);
1622
+ (0, exports.debug)(message);
1320
1623
  });
1321
1624
  return tr;
1322
1625
  }
@@ -1331,7 +1634,7 @@ exports.tool = tool;
1331
1634
  */
1332
1635
  function match(list, patterns, patternRoot, options) {
1333
1636
  // trace parameters
1334
- exports.debug("patternRoot: '" + patternRoot + "'");
1637
+ (0, exports.debug)("patternRoot: '".concat(patternRoot, "'"));
1335
1638
  options = options || _getDefaultMatchOptions(); // default match options
1336
1639
  _debugMatchOptions(options);
1337
1640
  // convert pattern to an array
@@ -1343,18 +1646,18 @@ function match(list, patterns, patternRoot, options) {
1343
1646
  var originalOptions = options;
1344
1647
  for (var _i = 0, patterns_1 = patterns; _i < patterns_1.length; _i++) {
1345
1648
  var pattern = patterns_1[_i];
1346
- exports.debug("pattern: '" + pattern + "'");
1649
+ (0, exports.debug)("pattern: '".concat(pattern, "'"));
1347
1650
  // trim and skip empty
1348
1651
  pattern = (pattern || '').trim();
1349
1652
  if (!pattern) {
1350
- exports.debug('skipping empty pattern');
1653
+ (0, exports.debug)('skipping empty pattern');
1351
1654
  continue;
1352
1655
  }
1353
1656
  // clone match options
1354
1657
  var options_1 = im._cloneMatchOptions(originalOptions);
1355
1658
  // skip comments
1356
1659
  if (!options_1.nocomment && im._startsWith(pattern, '#')) {
1357
- exports.debug('skipping comment');
1660
+ (0, exports.debug)('skipping comment');
1358
1661
  continue;
1359
1662
  }
1360
1663
  // set nocomment - brace expansion could result in a leading '#'
@@ -1367,7 +1670,7 @@ function match(list, patterns, patternRoot, options) {
1367
1670
  }
1368
1671
  pattern = pattern.substring(negateCount); // trim leading '!'
1369
1672
  if (negateCount) {
1370
- exports.debug("trimmed leading '!'. pattern: '" + pattern + "'");
1673
+ (0, exports.debug)("trimmed leading '!'. pattern: '".concat(pattern, "'"));
1371
1674
  }
1372
1675
  }
1373
1676
  var isIncludePattern = negateCount == 0 ||
@@ -1385,7 +1688,7 @@ function match(list, patterns, patternRoot, options) {
1385
1688
  else {
1386
1689
  // convert slashes on Windows before calling braceExpand(). unfortunately this means braces cannot
1387
1690
  // be escaped on Windows, this limitation is consistent with current limitations of minimatch (3.0.3).
1388
- exports.debug('expanding braces');
1691
+ (0, exports.debug)('expanding braces');
1389
1692
  var convertedPattern = process.platform == 'win32' ? pattern.replace(/\\/g, '/') : pattern;
1390
1693
  expanded = minimatch.braceExpand(convertedPattern);
1391
1694
  }
@@ -1394,12 +1697,12 @@ function match(list, patterns, patternRoot, options) {
1394
1697
  for (var _a = 0, expanded_1 = expanded; _a < expanded_1.length; _a++) {
1395
1698
  var pattern_1 = expanded_1[_a];
1396
1699
  if (expanded.length != 1 || pattern_1 != preExpanded) {
1397
- exports.debug("pattern: '" + pattern_1 + "'");
1700
+ (0, exports.debug)("pattern: '".concat(pattern_1, "'"));
1398
1701
  }
1399
1702
  // trim and skip empty
1400
1703
  pattern_1 = (pattern_1 || '').trim();
1401
1704
  if (!pattern_1) {
1402
- exports.debug('skipping empty pattern');
1705
+ (0, exports.debug)('skipping empty pattern');
1403
1706
  continue;
1404
1707
  }
1405
1708
  // root the pattern when all of the following conditions are true:
@@ -1408,13 +1711,13 @@ function match(list, patterns, patternRoot, options) {
1408
1711
  // AND matchBase:false or not basename only
1409
1712
  (!options_1.matchBase || (process.platform == 'win32' ? pattern_1.replace(/\\/g, '/') : pattern_1).indexOf('/') >= 0)) {
1410
1713
  pattern_1 = im._ensureRooted(patternRoot, pattern_1);
1411
- exports.debug("rooted pattern: '" + pattern_1 + "'");
1714
+ (0, exports.debug)("rooted pattern: '".concat(pattern_1, "'"));
1412
1715
  }
1413
1716
  if (isIncludePattern) {
1414
1717
  // apply the pattern
1415
- exports.debug('applying include pattern against original list');
1718
+ (0, exports.debug)('applying include pattern against original list');
1416
1719
  var matchResults = minimatch.match(list, pattern_1, options_1);
1417
- exports.debug(matchResults.length + ' matches');
1720
+ (0, exports.debug)(matchResults.length + ' matches');
1418
1721
  // union the results
1419
1722
  for (var _b = 0, matchResults_1 = matchResults; _b < matchResults_1.length; _b++) {
1420
1723
  var matchResult = matchResults_1[_b];
@@ -1423,9 +1726,9 @@ function match(list, patterns, patternRoot, options) {
1423
1726
  }
1424
1727
  else {
1425
1728
  // apply the pattern
1426
- exports.debug('applying exclude pattern against original list');
1729
+ (0, exports.debug)('applying exclude pattern against original list');
1427
1730
  var matchResults = minimatch.match(list, pattern_1, options_1);
1428
- exports.debug(matchResults.length + ' matches');
1731
+ (0, exports.debug)(matchResults.length + ' matches');
1429
1732
  // substract the results
1430
1733
  for (var _c = 0, matchResults_2 = matchResults; _c < matchResults_2.length; _c++) {
1431
1734
  var matchResult = matchResults_2[_c];
@@ -1436,7 +1739,7 @@ function match(list, patterns, patternRoot, options) {
1436
1739
  }
1437
1740
  // return a filtered version of the original list (preserves order and prevents duplication)
1438
1741
  var result = list.filter(function (item) { return map.hasOwnProperty(item); });
1439
- exports.debug(result.length + ' final results');
1742
+ (0, exports.debug)(result.length + ' final results');
1440
1743
  return result;
1441
1744
  }
1442
1745
  exports.match = match;
@@ -1452,17 +1755,17 @@ function filter(pattern, options) {
1452
1755
  }
1453
1756
  exports.filter = filter;
1454
1757
  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 + "'");
1758
+ (0, exports.debug)("matchOptions.debug: '".concat(options.debug, "'"));
1759
+ (0, exports.debug)("matchOptions.nobrace: '".concat(options.nobrace, "'"));
1760
+ (0, exports.debug)("matchOptions.noglobstar: '".concat(options.noglobstar, "'"));
1761
+ (0, exports.debug)("matchOptions.dot: '".concat(options.dot, "'"));
1762
+ (0, exports.debug)("matchOptions.noext: '".concat(options.noext, "'"));
1763
+ (0, exports.debug)("matchOptions.nocase: '".concat(options.nocase, "'"));
1764
+ (0, exports.debug)("matchOptions.nonull: '".concat(options.nonull, "'"));
1765
+ (0, exports.debug)("matchOptions.matchBase: '".concat(options.matchBase, "'"));
1766
+ (0, exports.debug)("matchOptions.nocomment: '".concat(options.nocomment, "'"));
1767
+ (0, exports.debug)("matchOptions.nonegate: '".concat(options.nonegate, "'"));
1768
+ (0, exports.debug)("matchOptions.flipNegate: '".concat(options.flipNegate, "'"));
1466
1769
  }
1467
1770
  function _getDefaultMatchOptions() {
1468
1771
  return {
@@ -1493,7 +1796,7 @@ function _getDefaultMatchOptions() {
1493
1796
  function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1494
1797
  // apply defaults for parameters and trace
1495
1798
  defaultRoot = defaultRoot || this.getVariable('system.defaultWorkingDirectory') || process.cwd();
1496
- exports.debug("defaultRoot: '" + defaultRoot + "'");
1799
+ (0, exports.debug)("defaultRoot: '".concat(defaultRoot, "'"));
1497
1800
  patterns = patterns || [];
1498
1801
  patterns = typeof patterns == 'string' ? [patterns] : patterns;
1499
1802
  findOptions = findOptions || _getDefaultFindOptions();
@@ -1506,18 +1809,18 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1506
1809
  var originalMatchOptions = matchOptions;
1507
1810
  for (var _i = 0, _a = (patterns || []); _i < _a.length; _i++) {
1508
1811
  var pattern = _a[_i];
1509
- exports.debug("pattern: '" + pattern + "'");
1812
+ (0, exports.debug)("pattern: '".concat(pattern, "'"));
1510
1813
  // trim and skip empty
1511
1814
  pattern = (pattern || '').trim();
1512
1815
  if (!pattern) {
1513
- exports.debug('skipping empty pattern');
1816
+ (0, exports.debug)('skipping empty pattern');
1514
1817
  continue;
1515
1818
  }
1516
1819
  // clone match options
1517
1820
  var matchOptions_1 = im._cloneMatchOptions(originalMatchOptions);
1518
1821
  // skip comments
1519
1822
  if (!matchOptions_1.nocomment && im._startsWith(pattern, '#')) {
1520
- exports.debug('skipping comment');
1823
+ (0, exports.debug)('skipping comment');
1521
1824
  continue;
1522
1825
  }
1523
1826
  // set nocomment - brace expansion could result in a leading '#'
@@ -1530,7 +1833,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1530
1833
  }
1531
1834
  pattern = pattern.substring(negateCount); // trim leading '!'
1532
1835
  if (negateCount) {
1533
- exports.debug("trimmed leading '!'. pattern: '" + pattern + "'");
1836
+ (0, exports.debug)("trimmed leading '!'. pattern: '".concat(pattern, "'"));
1534
1837
  }
1535
1838
  }
1536
1839
  var isIncludePattern = negateCount == 0 ||
@@ -1548,7 +1851,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1548
1851
  else {
1549
1852
  // convert slashes on Windows before calling braceExpand(). unfortunately this means braces cannot
1550
1853
  // be escaped on Windows, this limitation is consistent with current limitations of minimatch (3.0.3).
1551
- exports.debug('expanding braces');
1854
+ (0, exports.debug)('expanding braces');
1552
1855
  var convertedPattern = process.platform == 'win32' ? pattern.replace(/\\/g, '/') : pattern;
1553
1856
  expanded = minimatch.braceExpand(convertedPattern);
1554
1857
  }
@@ -1557,25 +1860,25 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1557
1860
  for (var _b = 0, expanded_2 = expanded; _b < expanded_2.length; _b++) {
1558
1861
  var pattern_2 = expanded_2[_b];
1559
1862
  if (expanded.length != 1 || pattern_2 != preExpanded) {
1560
- exports.debug("pattern: '" + pattern_2 + "'");
1863
+ (0, exports.debug)("pattern: '".concat(pattern_2, "'"));
1561
1864
  }
1562
1865
  // trim and skip empty
1563
1866
  pattern_2 = (pattern_2 || '').trim();
1564
1867
  if (!pattern_2) {
1565
- exports.debug('skipping empty pattern');
1868
+ (0, exports.debug)('skipping empty pattern');
1566
1869
  continue;
1567
1870
  }
1568
1871
  if (isIncludePattern) {
1569
1872
  // determine the findPath
1570
1873
  var findInfo = im._getFindInfoFromPattern(defaultRoot, pattern_2, matchOptions_1);
1571
1874
  var findPath = findInfo.findPath;
1572
- exports.debug("findPath: '" + findPath + "'");
1875
+ (0, exports.debug)("findPath: '".concat(findPath, "'"));
1573
1876
  if (!findPath) {
1574
- exports.debug('skipping empty path');
1877
+ (0, exports.debug)('skipping empty path');
1575
1878
  continue;
1576
1879
  }
1577
1880
  // perform the find
1578
- exports.debug("statOnly: '" + findInfo.statOnly + "'");
1881
+ (0, exports.debug)("statOnly: '".concat(findInfo.statOnly, "'"));
1579
1882
  var findResults = [];
1580
1883
  if (findInfo.statOnly) {
1581
1884
  // simply stat the path - all path segments were used to build the path
@@ -1587,21 +1890,21 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1587
1890
  if (err.code != 'ENOENT') {
1588
1891
  throw err;
1589
1892
  }
1590
- exports.debug('ENOENT');
1893
+ (0, exports.debug)('ENOENT');
1591
1894
  }
1592
1895
  }
1593
1896
  else {
1594
1897
  findResults = find(findPath, findOptions);
1595
1898
  }
1596
- exports.debug("found " + findResults.length + " paths");
1899
+ (0, exports.debug)("found ".concat(findResults.length, " paths"));
1597
1900
  // apply the pattern
1598
- exports.debug('applying include pattern');
1901
+ (0, exports.debug)('applying include pattern');
1599
1902
  if (findInfo.adjustedPattern != pattern_2) {
1600
- exports.debug("adjustedPattern: '" + findInfo.adjustedPattern + "'");
1903
+ (0, exports.debug)("adjustedPattern: '".concat(findInfo.adjustedPattern, "'"));
1601
1904
  pattern_2 = findInfo.adjustedPattern;
1602
1905
  }
1603
1906
  var matchResults = minimatch.match(findResults, pattern_2, matchOptions_1);
1604
- exports.debug(matchResults.length + ' matches');
1907
+ (0, exports.debug)(matchResults.length + ' matches');
1605
1908
  // union the results
1606
1909
  for (var _c = 0, matchResults_3 = matchResults; _c < matchResults_3.length; _c++) {
1607
1910
  var matchResult = matchResults_3[_c];
@@ -1615,17 +1918,17 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1615
1918
  !im._isRooted(pattern_2) &&
1616
1919
  (process.platform == 'win32' ? pattern_2.replace(/\\/g, '/') : pattern_2).indexOf('/') < 0) {
1617
1920
  // do not root the pattern
1618
- exports.debug('matchBase and basename only');
1921
+ (0, exports.debug)('matchBase and basename only');
1619
1922
  }
1620
1923
  else {
1621
1924
  // root the exclude pattern
1622
1925
  pattern_2 = im._ensurePatternRooted(defaultRoot, pattern_2);
1623
- exports.debug("after ensurePatternRooted, pattern: '" + pattern_2 + "'");
1926
+ (0, exports.debug)("after ensurePatternRooted, pattern: '".concat(pattern_2, "'"));
1624
1927
  }
1625
1928
  // apply the pattern
1626
- exports.debug('applying exclude pattern');
1929
+ (0, exports.debug)('applying exclude pattern');
1627
1930
  var matchResults = minimatch.match(Object.keys(results).map(function (key) { return results[key]; }), pattern_2, matchOptions_1);
1628
- exports.debug(matchResults.length + ' matches');
1931
+ (0, exports.debug)(matchResults.length + ' matches');
1629
1932
  // substract the results
1630
1933
  for (var _d = 0, matchResults_4 = matchResults; _d < matchResults_4.length; _d++) {
1631
1934
  var matchResult = matchResults_4[_d];
@@ -1638,7 +1941,7 @@ function findMatch(defaultRoot, patterns, findOptions, matchOptions) {
1638
1941
  var finalResult = Object.keys(results)
1639
1942
  .map(function (key) { return results[key]; })
1640
1943
  .sort();
1641
- exports.debug(finalResult.length + ' final results');
1944
+ (0, exports.debug)(finalResult.length + ' final results');
1642
1945
  return finalResult;
1643
1946
  }
1644
1947
  exports.findMatch = findMatch;
@@ -1651,9 +1954,9 @@ exports.findMatch = findMatch;
1651
1954
  */
1652
1955
  function getProxyFormattedUrl(proxyUrl, proxyUsername, proxyPassword) {
1653
1956
  var parsedUrl = new URL(proxyUrl);
1654
- var proxyAddress = parsedUrl.protocol + "//" + parsedUrl.host;
1957
+ var proxyAddress = "".concat(parsedUrl.protocol, "//").concat(parsedUrl.host);
1655
1958
  if (proxyUsername) {
1656
- proxyAddress = parsedUrl.protocol + "//" + proxyUsername + ":" + proxyPassword + "@" + parsedUrl.host;
1959
+ proxyAddress = "".concat(parsedUrl.protocol, "//").concat(proxyUsername, ":").concat(proxyPassword, "@").concat(parsedUrl.host);
1657
1960
  }
1658
1961
  return proxyAddress;
1659
1962
  }
@@ -1663,11 +1966,11 @@ function getProxyFormattedUrl(proxyUrl, proxyUsername, proxyPassword) {
1663
1966
  * @return ProxyConfiguration
1664
1967
  */
1665
1968
  function getHttpProxyConfiguration(requestUrl) {
1666
- var proxyUrl = exports.getVariable('Agent.ProxyUrl');
1969
+ var proxyUrl = (0, exports.getVariable)('Agent.ProxyUrl');
1667
1970
  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') || '[]');
1971
+ var proxyUsername = (0, exports.getVariable)('Agent.ProxyUsername');
1972
+ var proxyPassword = (0, exports.getVariable)('Agent.ProxyPassword');
1973
+ var proxyBypassHosts = JSON.parse((0, exports.getVariable)('Agent.ProxyBypassList') || '[]');
1671
1974
  var bypass_1 = false;
1672
1975
  if (requestUrl) {
1673
1976
  proxyBypassHosts.forEach(function (bypassHost) {
@@ -1701,16 +2004,16 @@ exports.getHttpProxyConfiguration = getHttpProxyConfiguration;
1701
2004
  * @return CertConfiguration
1702
2005
  */
1703
2006
  function getHttpCertConfiguration() {
1704
- var ca = exports.getVariable('Agent.CAInfo');
1705
- var clientCert = exports.getVariable('Agent.ClientCert');
2007
+ var ca = (0, exports.getVariable)('Agent.CAInfo');
2008
+ var clientCert = (0, exports.getVariable)('Agent.ClientCert');
1706
2009
  if (ca || clientCert) {
1707
2010
  var certConfig = {};
1708
2011
  certConfig.caFile = ca;
1709
2012
  certConfig.certFile = clientCert;
1710
2013
  if (clientCert) {
1711
- var clientCertKey = exports.getVariable('Agent.ClientCertKey');
1712
- var clientCertArchive = exports.getVariable('Agent.ClientCertArchive');
1713
- var clientCertPassword = exports.getVariable('Agent.ClientCertPassword');
2014
+ var clientCertKey = (0, exports.getVariable)('Agent.ClientCertKey');
2015
+ var clientCertArchive = (0, exports.getVariable)('Agent.ClientCertArchive');
2016
+ var clientCertPassword = (0, exports.getVariable)('Agent.ClientCertPassword');
1714
2017
  certConfig.keyFile = clientCertKey;
1715
2018
  certConfig.certArchiveFile = clientCertArchive;
1716
2019
  certConfig.passphrase = clientCertPassword;
@@ -1754,7 +2057,7 @@ var TestPublisher = /** @class */ (function () {
1754
2057
  properties['resultFiles'] = Array.isArray(resultFiles) ? resultFiles.join() : resultFiles;
1755
2058
  }
1756
2059
  properties['testRunSystem'] = testRunSystem;
1757
- exports.command('results.publish', properties, '');
2060
+ (0, exports.command)('results.publish', properties, '');
1758
2061
  };
1759
2062
  return TestPublisher;
1760
2063
  }());
@@ -1779,7 +2082,7 @@ var CodeCoveragePublisher = /** @class */ (function () {
1779
2082
  if (additionalCodeCoverageFiles) {
1780
2083
  properties['additionalcodecoveragefiles'] = Array.isArray(additionalCodeCoverageFiles) ? additionalCodeCoverageFiles.join() : additionalCodeCoverageFiles;
1781
2084
  }
1782
- exports.command('codecoverage.publish', properties, "");
2085
+ (0, exports.command)('codecoverage.publish', properties, "");
1783
2086
  };
1784
2087
  return CodeCoveragePublisher;
1785
2088
  }());
@@ -1795,7 +2098,7 @@ var CodeCoverageEnabler = /** @class */ (function () {
1795
2098
  CodeCoverageEnabler.prototype.enableCodeCoverage = function (buildProps) {
1796
2099
  buildProps['buildtool'] = this.buildTool;
1797
2100
  buildProps['codecoveragetool'] = this.ccTool;
1798
- exports.command('codecoverage.enable', buildProps, "");
2101
+ (0, exports.command)('codecoverage.enable', buildProps, "");
1799
2102
  };
1800
2103
  return CodeCoverageEnabler;
1801
2104
  }());
@@ -1813,7 +2116,7 @@ exports.CodeCoverageEnabler = CodeCoverageEnabler;
1813
2116
  * @returns void
1814
2117
  */
1815
2118
  function uploadFile(path) {
1816
- exports.command("task.uploadfile", null, path);
2119
+ (0, exports.command)("task.uploadfile", null, path);
1817
2120
  }
1818
2121
  exports.uploadFile = uploadFile;
1819
2122
  /**
@@ -1826,7 +2129,7 @@ exports.uploadFile = uploadFile;
1826
2129
  */
1827
2130
  function prependPath(path) {
1828
2131
  assertAgent("2.115.0");
1829
- exports.command("task.prependpath", null, path);
2132
+ (0, exports.command)("task.prependpath", null, path);
1830
2133
  }
1831
2134
  exports.prependPath = prependPath;
1832
2135
  /**
@@ -1838,7 +2141,7 @@ exports.prependPath = prependPath;
1838
2141
  * @returns void
1839
2142
  */
1840
2143
  function uploadSummary(path) {
1841
- exports.command("task.uploadsummary", null, path);
2144
+ (0, exports.command)("task.uploadsummary", null, path);
1842
2145
  }
1843
2146
  exports.uploadSummary = uploadSummary;
1844
2147
  /**
@@ -1852,7 +2155,7 @@ exports.uploadSummary = uploadSummary;
1852
2155
  * @returns void
1853
2156
  */
1854
2157
  function addAttachment(type, name, path) {
1855
- exports.command("task.addattachment", { "type": type, "name": name }, path);
2158
+ (0, exports.command)("task.addattachment", { "type": type, "name": name }, path);
1856
2159
  }
1857
2160
  exports.addAttachment = addAttachment;
1858
2161
  /**
@@ -1867,7 +2170,7 @@ exports.addAttachment = addAttachment;
1867
2170
  * @returns void
1868
2171
  */
1869
2172
  function setEndpoint(id, field, key, value) {
1870
- exports.command("task.setendpoint", { "id": id, "field": FieldType[field].toLowerCase(), "key": key }, value);
2173
+ (0, exports.command)("task.setendpoint", { "id": id, "field": FieldType[field].toLowerCase(), "key": key }, value);
1871
2174
  }
1872
2175
  exports.setEndpoint = setEndpoint;
1873
2176
  /**
@@ -1878,7 +2181,7 @@ exports.setEndpoint = setEndpoint;
1878
2181
  * @returns void
1879
2182
  */
1880
2183
  function setProgress(percent, currentOperation) {
1881
- exports.command("task.setprogress", { "value": "" + percent }, currentOperation);
2184
+ (0, exports.command)("task.setprogress", { "value": "".concat(percent) }, currentOperation);
1882
2185
  }
1883
2186
  exports.setProgress = setProgress;
1884
2187
  /**
@@ -1910,7 +2213,7 @@ function logDetail(id, message, parentId, recordType, recordName, order, startTi
1910
2213
  "state": state ? TaskState[state] : undefined,
1911
2214
  "result": result ? TaskResult[result] : undefined
1912
2215
  };
1913
- exports.command("task.logdetail", properties, message);
2216
+ (0, exports.command)("task.logdetail", properties, message);
1914
2217
  }
1915
2218
  exports.logDetail = logDetail;
1916
2219
  /**
@@ -1932,7 +2235,7 @@ function logIssue(type, message, sourcePath, lineNumber, columnNumber, errorCode
1932
2235
  "linenumber": lineNumber ? lineNumber.toString() : undefined,
1933
2236
  "columnnumber": columnNumber ? columnNumber.toString() : undefined,
1934
2237
  };
1935
- exports.command("task.logissue", properties, message);
2238
+ (0, exports.command)("task.logissue", properties, message);
1936
2239
  }
1937
2240
  exports.logIssue = logIssue;
1938
2241
  //-----------------------------------------------------
@@ -1950,7 +2253,7 @@ exports.logIssue = logIssue;
1950
2253
  * @returns void
1951
2254
  */
1952
2255
  function uploadArtifact(containerFolder, path, name) {
1953
- exports.command("artifact.upload", { "containerfolder": containerFolder, "artifactname": name }, path);
2256
+ (0, exports.command)("artifact.upload", { "containerfolder": containerFolder, "artifactname": name }, path);
1954
2257
  }
1955
2258
  exports.uploadArtifact = uploadArtifact;
1956
2259
  /**
@@ -1965,7 +2268,7 @@ exports.uploadArtifact = uploadArtifact;
1965
2268
  * @returns void
1966
2269
  */
1967
2270
  function associateArtifact(name, path, artifactType) {
1968
- exports.command("artifact.associate", { "type": ArtifactType[artifactType].toLowerCase(), "artifactname": name }, path);
2271
+ (0, exports.command)("artifact.associate", { "type": ArtifactType[artifactType].toLowerCase(), "artifactname": name }, path);
1969
2272
  }
1970
2273
  exports.associateArtifact = associateArtifact;
1971
2274
  //-----------------------------------------------------
@@ -1978,7 +2281,7 @@ exports.associateArtifact = associateArtifact;
1978
2281
  * @returns void
1979
2282
  */
1980
2283
  function uploadBuildLog(path) {
1981
- exports.command("build.uploadlog", null, path);
2284
+ (0, exports.command)("build.uploadlog", null, path);
1982
2285
  }
1983
2286
  exports.uploadBuildLog = uploadBuildLog;
1984
2287
  /**
@@ -1988,7 +2291,7 @@ exports.uploadBuildLog = uploadBuildLog;
1988
2291
  * @returns void
1989
2292
  */
1990
2293
  function updateBuildNumber(value) {
1991
- exports.command("build.updatebuildnumber", null, value);
2294
+ (0, exports.command)("build.updatebuildnumber", null, value);
1992
2295
  }
1993
2296
  exports.updateBuildNumber = updateBuildNumber;
1994
2297
  /**
@@ -1998,7 +2301,7 @@ exports.updateBuildNumber = updateBuildNumber;
1998
2301
  * @returns void
1999
2302
  */
2000
2303
  function addBuildTag(value) {
2001
- exports.command("build.addbuildtag", null, value);
2304
+ (0, exports.command)("build.addbuildtag", null, value);
2002
2305
  }
2003
2306
  exports.addBuildTag = addBuildTag;
2004
2307
  //-----------------------------------------------------
@@ -2012,7 +2315,7 @@ exports.addBuildTag = addBuildTag;
2012
2315
  */
2013
2316
  function updateReleaseName(name) {
2014
2317
  assertAgent("2.132.0");
2015
- exports.command("release.updatereleasename", null, name);
2318
+ (0, exports.command)("release.updatereleasename", null, name);
2016
2319
  }
2017
2320
  exports.updateReleaseName = updateReleaseName;
2018
2321
  //-----------------------------------------------------
@@ -2026,7 +2329,7 @@ exports.ToolRunner = trm.ToolRunner;
2026
2329
  //-----------------------------------------------------
2027
2330
  // async await needs generators in node 4.x+
2028
2331
  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');
2332
+ (0, exports.warning)('Tasks require a new agent. Upgrade your agent or node to 4.2.0 or later', exports.IssueSource.TaskInternal);
2030
2333
  }
2031
2334
  //-------------------------------------------------------------------
2032
2335
  // Populate the vault with sensitive data. Inputs and Endpoints