| 709 | } |
| 710 | |
| 711 | function findFile (dir, regexp, callback) { |
| 712 | fs.readdir(dir, {withFileTypes: true}, (err, files) => { |
| 713 | if (err) { |
| 714 | console.error('Cannot lookup for file', dir); |
| 715 | callback(null); |
| 716 | } else { |
| 717 | for (let i = 0; i < files.length; i++) { |
| 718 | const fileName = files[i].name; |
| 719 | let match = fileName.match(regexp); |
| 720 | if (match && match.length) { |
| 721 | if (match[0].length === fileName.length) { |
| 722 | callback(fileName); |
| 723 | return; |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | console.error('None of the files match regexp!', regexp, JSON.stringify(files)); |
| 728 | callback(null); |
| 729 | } |
| 730 | }); |
| 731 | } |
| 732 | |
| 733 | function toDisplayAlgorithm (algorithm) { |
| 734 | switch (algorithm) { |