azure-pipelines-task-lib 5.1.0 → 5.2.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 +39 -13
package/package.json
CHANGED
package/task.js
CHANGED
|
@@ -149,8 +149,9 @@ function assertAgent(minimum) {
|
|
|
149
149
|
throw new Error('assertAgent() requires the parameter to be 2.104.1 or higher');
|
|
150
150
|
}
|
|
151
151
|
var agent = (0, exports.getVariable)('Agent.Version');
|
|
152
|
+
(0, exports.debug)('Detected Agent.Version=' + (agent ? agent : 'undefined'));
|
|
152
153
|
if (agent && semver.lt(agent, minimum)) {
|
|
153
|
-
throw new Error("Agent version ".concat(minimum, " or higher is required"));
|
|
154
|
+
throw new Error("Agent version ".concat(minimum, " or higher is required. Detected Agent version: ").concat(agent));
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
exports.assertAgent = assertAgent;
|
|
@@ -906,9 +907,8 @@ function ls(optionsOrPaths) {
|
|
|
906
907
|
isRecursive = options.includes('r');
|
|
907
908
|
includeHidden = options.includes('a');
|
|
908
909
|
}
|
|
909
|
-
// Flatten paths if the paths argument is array
|
|
910
910
|
if (Array.isArray(paths)) {
|
|
911
|
-
paths = paths
|
|
911
|
+
paths = flattenArray(paths);
|
|
912
912
|
}
|
|
913
913
|
// If the first argument is not options, then it is a path
|
|
914
914
|
if (typeof optionsOrPaths !== 'string' || !optionsOrPaths.startsWith('-')) {
|
|
@@ -931,7 +931,25 @@ function ls(optionsOrPaths) {
|
|
|
931
931
|
}
|
|
932
932
|
var pathsCopy = __spreadArray([], paths, true);
|
|
933
933
|
var preparedPaths = [];
|
|
934
|
+
var fileEntries = [];
|
|
934
935
|
try {
|
|
936
|
+
var remainingPaths = [];
|
|
937
|
+
while (paths.length > 0) {
|
|
938
|
+
var pathEntry = resolve(paths.shift());
|
|
939
|
+
if (pathEntry === null || pathEntry === void 0 ? void 0 : pathEntry.includes('*')) {
|
|
940
|
+
remainingPaths.push(pathEntry);
|
|
941
|
+
continue;
|
|
942
|
+
}
|
|
943
|
+
var stats_2 = fs.lstatSync(pathEntry);
|
|
944
|
+
if (stats_2.isFile()) {
|
|
945
|
+
var fileName = path.basename(pathEntry);
|
|
946
|
+
fileEntries.push(fileName);
|
|
947
|
+
}
|
|
948
|
+
else {
|
|
949
|
+
remainingPaths.push(pathEntry);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
paths.push.apply(paths, remainingPaths);
|
|
935
953
|
var _loop_1 = function () {
|
|
936
954
|
var pathEntry = resolve(paths.shift());
|
|
937
955
|
if (pathEntry === null || pathEntry === void 0 ? void 0 : pathEntry.includes('*')) {
|
|
@@ -971,7 +989,8 @@ function ls(optionsOrPaths) {
|
|
|
971
989
|
while (preparedPaths.length > 0) {
|
|
972
990
|
_loop_2();
|
|
973
991
|
}
|
|
974
|
-
|
|
992
|
+
var finalResults = __spreadArray(__spreadArray([], fileEntries, true), entries, true);
|
|
993
|
+
return finalResults;
|
|
975
994
|
}
|
|
976
995
|
catch (error) {
|
|
977
996
|
if (error.code === 'ENOENT') {
|
|
@@ -983,6 +1002,11 @@ function ls(optionsOrPaths) {
|
|
|
983
1002
|
}
|
|
984
1003
|
}
|
|
985
1004
|
exports.ls = ls;
|
|
1005
|
+
function flattenArray(arr) {
|
|
1006
|
+
return arr.reduce(function (flat, toFlatten) {
|
|
1007
|
+
return flat.concat(Array.isArray(toFlatten) ? flattenArray(toFlatten) : toFlatten);
|
|
1008
|
+
}, []);
|
|
1009
|
+
}
|
|
986
1010
|
/**
|
|
987
1011
|
* Copies a file or folder.
|
|
988
1012
|
* @param {string} sourceOrOptions - Either the source path or an option string '-r', '-f' , '-n' or '-rfn' for recursive, force and no-clobber.
|
|
@@ -1024,7 +1048,8 @@ function cp(sourceOrOptions, destinationOrSource, optionsOrDestination, continue
|
|
|
1024
1048
|
}
|
|
1025
1049
|
try {
|
|
1026
1050
|
if (lstatSource.isSymbolicLink()) {
|
|
1027
|
-
|
|
1051
|
+
var symlinkTarget = fs.readlinkSync(source);
|
|
1052
|
+
source = path.resolve(path.dirname(source), symlinkTarget);
|
|
1028
1053
|
lstatSource = fs.lstatSync(source);
|
|
1029
1054
|
}
|
|
1030
1055
|
if (lstatSource.isFile()) {
|
|
@@ -1062,7 +1087,8 @@ var copyDirectoryWithResolvedSymlinks = function (src, dest, force) {
|
|
|
1062
1087
|
destPath = path.join(dest, entry.name);
|
|
1063
1088
|
if (entry.isSymbolicLink()) {
|
|
1064
1089
|
// Resolve the symbolic link and copy the target
|
|
1065
|
-
var
|
|
1090
|
+
var symlinkTarget = fs.readlinkSync(srcPath);
|
|
1091
|
+
var resolvedPath = path.resolve(path.dirname(srcPath), symlinkTarget);
|
|
1066
1092
|
var stat = fs.lstatSync(resolvedPath);
|
|
1067
1093
|
if (stat.isFile()) {
|
|
1068
1094
|
// Use the actual target file's name instead of the symbolic link's name
|
|
@@ -1234,7 +1260,7 @@ function find(findPath, options) {
|
|
|
1234
1260
|
var _loop_3 = function () {
|
|
1235
1261
|
// pop the next item and push to the result array
|
|
1236
1262
|
var item = stack.pop(); // non-null because `stack.length` was truthy
|
|
1237
|
-
var
|
|
1263
|
+
var stats_3 = void 0;
|
|
1238
1264
|
try {
|
|
1239
1265
|
// `item.path` equals `findPath` for the first item to be processed, when the `result` array is empty
|
|
1240
1266
|
var isPathToSearch = !result.length;
|
|
@@ -1243,7 +1269,7 @@ function find(findPath, options) {
|
|
|
1243
1269
|
// following all symlinks or following symlink for the specified path
|
|
1244
1270
|
var followSymbolicLink = options.followSymbolicLinks || followSpecifiedSymbolicLink;
|
|
1245
1271
|
// stat the item. The stat info is used further below to determine whether to traverse deeper
|
|
1246
|
-
|
|
1272
|
+
stats_3 = _getStats(item.path, followSymbolicLink, options.allowBrokenSymbolicLinks);
|
|
1247
1273
|
}
|
|
1248
1274
|
catch (err) {
|
|
1249
1275
|
if (err.code == 'ENOENT' && options.skipMissingFiles) {
|
|
@@ -1254,7 +1280,7 @@ function find(findPath, options) {
|
|
|
1254
1280
|
}
|
|
1255
1281
|
result.push(item.path);
|
|
1256
1282
|
// note, isDirectory() returns false for the lstat of a symlink
|
|
1257
|
-
if (
|
|
1283
|
+
if (stats_3.isDirectory()) {
|
|
1258
1284
|
(0, exports.debug)(" ".concat(item.path, " (directory)"));
|
|
1259
1285
|
if (options.followSymbolicLinks) {
|
|
1260
1286
|
// get the realpath
|
|
@@ -1502,8 +1528,8 @@ function rmRF(inputPath) {
|
|
|
1502
1528
|
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1503
1529
|
var realPath = fs.readlinkSync(inputPath);
|
|
1504
1530
|
if (fs.existsSync(realPath)) {
|
|
1505
|
-
var
|
|
1506
|
-
if (
|
|
1531
|
+
var stats_4 = fs.statSync(realPath);
|
|
1532
|
+
if (stats_4.isDirectory()) {
|
|
1507
1533
|
childProcess.execFileSync("cmd.exe", ["/c", "rd", "/s", "/q", realPath]);
|
|
1508
1534
|
fs.unlinkSync(inputPath);
|
|
1509
1535
|
}
|
|
@@ -1548,8 +1574,8 @@ function rmRF(inputPath) {
|
|
|
1548
1574
|
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1549
1575
|
var realPath = fs.readlinkSync(inputPath);
|
|
1550
1576
|
if (fs.existsSync(realPath)) {
|
|
1551
|
-
var
|
|
1552
|
-
if (
|
|
1577
|
+
var stats_5 = fs.statSync(realPath);
|
|
1578
|
+
if (stats_5.isDirectory()) {
|
|
1553
1579
|
fs.rmSync(realPath, { recursive: true, force: true });
|
|
1554
1580
|
fs.unlinkSync(inputPath);
|
|
1555
1581
|
}
|