in lib/files/file_manager.ts [110:143]
static downloadedVersions_<T extends Binary>(
binary: T, osType: string, arch: string, existingFiles: string[]): DownloadedBinary {
let versions: string[] = [];
for (let existPos in existingFiles) {
let existFile: string = existingFiles[existPos];
// use only files that have a prefix and suffix that we care about
if (existFile.indexOf(binary.prefix()) === 0) {
let editExistFile = existFile.replace(binary.prefix(), '');
// if the suffix matches the executable suffix, add it
if (binary.suffix() === binary.executableSuffix()) {
versions.push(editExistFile.replace(binary.suffix(), ''));
}
// if the suffix does not match the executable,
// the binary is something like: .exe and .zip
// TODO(cnishina): fix implementation. Suffix method is dependent on the version number
// example: chromedriver < 2.23 has a different suffix than 2.23+ (mac32.zip vs mac64.zip).
else if (
!existFile.endsWith('.zip') && !existFile.endsWith('.tar.gz') &&
existFile.indexOf(binary.suffix()) === -1) {
editExistFile = editExistFile.replace(binary.executableSuffix(), '');
editExistFile = editExistFile.indexOf('_') === 0 ?
editExistFile.substring(1, editExistFile.length) :
editExistFile;
versions.push(editExistFile);
}
}
}
if (versions.length === 0) {
return null;
}
let downloadedBinary = new DownloadedBinary(binary);
downloadedBinary.versions = versions;
return downloadedBinary;
}