diff --git a/Tasks/CopyFilesV2/copyfiles.ts b/Tasks/CopyFilesV2/copyfiles.ts index 138e31767518..bfa0f94bff5a 100644 --- a/Tasks/CopyFilesV2/copyfiles.ts +++ b/Tasks/CopyFilesV2/copyfiles.ts @@ -2,6 +2,14 @@ import fs = require('fs'); import path = require('path'); import tl = require('azure-pipelines-task-lib/task'); + +// we allow broken symlinks - since there could be broken symlinks found in source folder, but filtered by contents pattern +const findOptions: tl.FindOptions = { + allowBrokenSymbolicLinks: true, + followSpecifiedSymbolicLink: true, + followSymbolicLinks: true +}; + tl.setResourcePath(path.join(__dirname, 'task.json')); // contents is a multiline input containing glob patterns @@ -16,13 +24,7 @@ const preserveTimestamp: boolean = tl.getBoolInput('preserveTimestamp', false); // normalize the source folder path. this is important for later in order to accurately // determine the relative path of each found file (substring using sourceFolder.length). sourceFolder = path.normalize(sourceFolder); -// we allow broken symlinks - since there could be broken symlinks found in source folder, but filtered by contents pattern -let allPaths: string[] = tl.find(sourceFolder, - { - allowBrokenSymbolicLinks: true, - followSpecifiedSymbolicLink: true, - followSymbolicLinks: true - }); +let allPaths: string[] = tl.find(sourceFolder, findOptions); let sourceFolderPattern = sourceFolder.replace('[', '[[]'); // directories can have [] in them, and they have special meanings as a pattern, so escape them let matchedPaths: string[] = tl.match(allPaths, contents, sourceFolderPattern); // default match options let matchedFiles: string[] = matchedPaths.filter((itemPath: string) => !tl.stats(itemPath).isDirectory()); // filter-out directories