azure-pipelines-task-lib 5.2.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 +33 -10
package/package.json
CHANGED
package/task.js
CHANGED
|
@@ -907,9 +907,8 @@ function ls(optionsOrPaths) {
|
|
|
907
907
|
isRecursive = options.includes('r');
|
|
908
908
|
includeHidden = options.includes('a');
|
|
909
909
|
}
|
|
910
|
-
// Flatten paths if the paths argument is array
|
|
911
910
|
if (Array.isArray(paths)) {
|
|
912
|
-
paths = paths
|
|
911
|
+
paths = flattenArray(paths);
|
|
913
912
|
}
|
|
914
913
|
// If the first argument is not options, then it is a path
|
|
915
914
|
if (typeof optionsOrPaths !== 'string' || !optionsOrPaths.startsWith('-')) {
|
|
@@ -932,7 +931,25 @@ function ls(optionsOrPaths) {
|
|
|
932
931
|
}
|
|
933
932
|
var pathsCopy = __spreadArray([], paths, true);
|
|
934
933
|
var preparedPaths = [];
|
|
934
|
+
var fileEntries = [];
|
|
935
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);
|
|
936
953
|
var _loop_1 = function () {
|
|
937
954
|
var pathEntry = resolve(paths.shift());
|
|
938
955
|
if (pathEntry === null || pathEntry === void 0 ? void 0 : pathEntry.includes('*')) {
|
|
@@ -972,7 +989,8 @@ function ls(optionsOrPaths) {
|
|
|
972
989
|
while (preparedPaths.length > 0) {
|
|
973
990
|
_loop_2();
|
|
974
991
|
}
|
|
975
|
-
|
|
992
|
+
var finalResults = __spreadArray(__spreadArray([], fileEntries, true), entries, true);
|
|
993
|
+
return finalResults;
|
|
976
994
|
}
|
|
977
995
|
catch (error) {
|
|
978
996
|
if (error.code === 'ENOENT') {
|
|
@@ -984,6 +1002,11 @@ function ls(optionsOrPaths) {
|
|
|
984
1002
|
}
|
|
985
1003
|
}
|
|
986
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
|
+
}
|
|
987
1010
|
/**
|
|
988
1011
|
* Copies a file or folder.
|
|
989
1012
|
* @param {string} sourceOrOptions - Either the source path or an option string '-r', '-f' , '-n' or '-rfn' for recursive, force and no-clobber.
|
|
@@ -1237,7 +1260,7 @@ function find(findPath, options) {
|
|
|
1237
1260
|
var _loop_3 = function () {
|
|
1238
1261
|
// pop the next item and push to the result array
|
|
1239
1262
|
var item = stack.pop(); // non-null because `stack.length` was truthy
|
|
1240
|
-
var
|
|
1263
|
+
var stats_3 = void 0;
|
|
1241
1264
|
try {
|
|
1242
1265
|
// `item.path` equals `findPath` for the first item to be processed, when the `result` array is empty
|
|
1243
1266
|
var isPathToSearch = !result.length;
|
|
@@ -1246,7 +1269,7 @@ function find(findPath, options) {
|
|
|
1246
1269
|
// following all symlinks or following symlink for the specified path
|
|
1247
1270
|
var followSymbolicLink = options.followSymbolicLinks || followSpecifiedSymbolicLink;
|
|
1248
1271
|
// stat the item. The stat info is used further below to determine whether to traverse deeper
|
|
1249
|
-
|
|
1272
|
+
stats_3 = _getStats(item.path, followSymbolicLink, options.allowBrokenSymbolicLinks);
|
|
1250
1273
|
}
|
|
1251
1274
|
catch (err) {
|
|
1252
1275
|
if (err.code == 'ENOENT' && options.skipMissingFiles) {
|
|
@@ -1257,7 +1280,7 @@ function find(findPath, options) {
|
|
|
1257
1280
|
}
|
|
1258
1281
|
result.push(item.path);
|
|
1259
1282
|
// note, isDirectory() returns false for the lstat of a symlink
|
|
1260
|
-
if (
|
|
1283
|
+
if (stats_3.isDirectory()) {
|
|
1261
1284
|
(0, exports.debug)(" ".concat(item.path, " (directory)"));
|
|
1262
1285
|
if (options.followSymbolicLinks) {
|
|
1263
1286
|
// get the realpath
|
|
@@ -1505,8 +1528,8 @@ function rmRF(inputPath) {
|
|
|
1505
1528
|
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1506
1529
|
var realPath = fs.readlinkSync(inputPath);
|
|
1507
1530
|
if (fs.existsSync(realPath)) {
|
|
1508
|
-
var
|
|
1509
|
-
if (
|
|
1531
|
+
var stats_4 = fs.statSync(realPath);
|
|
1532
|
+
if (stats_4.isDirectory()) {
|
|
1510
1533
|
childProcess.execFileSync("cmd.exe", ["/c", "rd", "/s", "/q", realPath]);
|
|
1511
1534
|
fs.unlinkSync(inputPath);
|
|
1512
1535
|
}
|
|
@@ -1551,8 +1574,8 @@ function rmRF(inputPath) {
|
|
|
1551
1574
|
(0, exports.debug)('removing symbolic link ' + inputPath);
|
|
1552
1575
|
var realPath = fs.readlinkSync(inputPath);
|
|
1553
1576
|
if (fs.existsSync(realPath)) {
|
|
1554
|
-
var
|
|
1555
|
-
if (
|
|
1577
|
+
var stats_5 = fs.statSync(realPath);
|
|
1578
|
+
if (stats_5.isDirectory()) {
|
|
1556
1579
|
fs.rmSync(realPath, { recursive: true, force: true });
|
|
1557
1580
|
fs.unlinkSync(inputPath);
|
|
1558
1581
|
}
|