Skip to content

Commit

Permalink
Moved find options to separate object
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatolii Bolshakov (Akvelon INC) committed Oct 27, 2020
1 parent fa3af26 commit 12be6fe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Tasks/CopyFilesV2/copyfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 12be6fe

Please sign in to comment.