azure-pipelines-task-lib 5.281.0 → 5.281.1
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/package.json +1 -1
- package/task.js +48 -5
package/package.json
CHANGED
package/task.js
CHANGED
|
@@ -1533,6 +1533,50 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
|
|
|
1533
1533
|
}
|
|
1534
1534
|
return Object.keys(allFiles).sort();
|
|
1535
1535
|
}
|
|
1536
|
+
function _quoteWindowsCmdPath(value) {
|
|
1537
|
+
// Percent expansion remains active inside quotes, so quote each literal percent separately.
|
|
1538
|
+
return "\"".concat(value.replace(/%/g, '"^%"'), "\"");
|
|
1539
|
+
}
|
|
1540
|
+
function _publishRmRFSpecialPathTelemetry(inputPath) {
|
|
1541
|
+
try {
|
|
1542
|
+
var hasPercent = inputPath.includes('%');
|
|
1543
|
+
var hasCmdMetachar = /[&|<>^]/.test(inputPath);
|
|
1544
|
+
var hasDelayedExpansion = inputPath.includes('!');
|
|
1545
|
+
var hasParentheses = /[()]/.test(inputPath);
|
|
1546
|
+
if (!hasPercent && !hasCmdMetachar && !hasDelayedExpansion && !hasParentheses) {
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
var message = JSON.stringify({
|
|
1550
|
+
event: 'SpecialPathDetected',
|
|
1551
|
+
hasPercent: hasPercent,
|
|
1552
|
+
hasCmdMetachar: hasCmdMetachar,
|
|
1553
|
+
hasDelayedExpansion: hasDelayedExpansion,
|
|
1554
|
+
hasParentheses: hasParentheses
|
|
1555
|
+
});
|
|
1556
|
+
console.log("##vso[telemetry.publish area=TaskHub;feature=TaskLibRmRF]".concat(message));
|
|
1557
|
+
}
|
|
1558
|
+
catch (err) {
|
|
1559
|
+
(0, exports.debug)("Failed to publish rmRF telemetry: ".concat(err.message));
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
function _rmWindows(targetPath, isDirectory) {
|
|
1563
|
+
var normalizedPath = im._normalizeSeparators(targetPath);
|
|
1564
|
+
if (!getPipelineFeature('EnableRmRFCommandPathQuoting')) {
|
|
1565
|
+
var legacyArgs = isDirectory
|
|
1566
|
+
? ['/c', 'rd', '/s', '/q', normalizedPath]
|
|
1567
|
+
: ['/c', 'del', '/f', '/a', normalizedPath];
|
|
1568
|
+
childProcess.execFileSync('cmd.exe', legacyArgs);
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
var quotedPath = _quoteWindowsCmdPath(normalizedPath);
|
|
1572
|
+
var args = isDirectory
|
|
1573
|
+
? ['/d', '/v:off', '/c', 'rd', '/s', '/q', quotedPath]
|
|
1574
|
+
: ['/d', '/v:off', '/c', 'del', '/f', '/a', quotedPath];
|
|
1575
|
+
var options = {
|
|
1576
|
+
windowsVerbatimArguments: true
|
|
1577
|
+
};
|
|
1578
|
+
childProcess.execFileSync('cmd.exe', args, options);
|
|
1579
|
+
}
|
|
1536
1580
|
/**
|
|
1537
1581
|
* Remove a path recursively with force
|
|
1538
1582
|
*
|
|
@@ -1543,13 +1587,12 @@ function _legacyFindFiles_getMatchingItems(includePatterns, excludePatterns, inc
|
|
|
1543
1587
|
function rmRF(inputPath) {
|
|
1544
1588
|
(0, exports.debug)('rm -rf ' + inputPath);
|
|
1545
1589
|
if (getPlatform() == Platform.Windows) {
|
|
1546
|
-
|
|
1547
|
-
// program (e.g. antivirus), it won't be deleted. To address this, we shell out the work to rd/del.
|
|
1590
|
+
_publishRmRFSpecialPathTelemetry(inputPath);
|
|
1548
1591
|
try {
|
|
1549
1592
|
var lstats = fs.lstatSync(inputPath);
|
|
1550
1593
|
if (lstats.isDirectory() && !lstats.isSymbolicLink()) {
|
|
1551
1594
|
(0, exports.debug)('removing directory ' + inputPath);
|
|
1552
|
-
|
|
1595
|
+
_rmWindows(inputPath, true);
|
|
1553
1596
|
}
|
|
1554
1597
|
else if (lstats.isSymbolicLink()) {
|
|
1555
1598
|
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
@@ -1557,7 +1600,7 @@ function rmRF(inputPath) {
|
|
|
1557
1600
|
if (fs.existsSync(realPath)) {
|
|
1558
1601
|
var stats_4 = fs.statSync(realPath);
|
|
1559
1602
|
if (stats_4.isDirectory()) {
|
|
1560
|
-
|
|
1603
|
+
_rmWindows(realPath, true);
|
|
1561
1604
|
fs.unlinkSync(inputPath);
|
|
1562
1605
|
}
|
|
1563
1606
|
else {
|
|
@@ -1571,7 +1614,7 @@ function rmRF(inputPath) {
|
|
|
1571
1614
|
}
|
|
1572
1615
|
else {
|
|
1573
1616
|
(0, exports.debug)('removing file ' + inputPath);
|
|
1574
|
-
|
|
1617
|
+
_rmWindows(inputPath, false);
|
|
1575
1618
|
}
|
|
1576
1619
|
}
|
|
1577
1620
|
catch (err) {
|