diff --git a/lib/common-utils.ts b/lib/common-utils.ts index e4bd3f881..21cab4651 100644 --- a/lib/common-utils.ts +++ b/lib/common-utils.ts @@ -44,3 +44,14 @@ export function remove(arr: U[], v: V) { return arr.filter(item => item !== v) as Exclude[]; } // https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVysAWwgDdgAeAVQBo4A1OUGYFAEwGc4KA+ACgEMoUAFycA2gF0axEbQCUcAN4AoOKrzAYSKLgFQAdAkwAbJlB6YmBOAF4ucC4TgBCa9bjF5fDgFEQaI0gs5NR0DCBMrBwoSEZGcAA+cKhBhijALHAA-KEiaaRQXBIA3EoAvkpKQf4CwHBoOGzwuiI8jVCYKADmCXDRsbLFFfUojXAgNupEpPyCNH1GsiUA9EtqcAB6mUMN8ACeE-hTwDNQNABECBAQZ4tKK2ubFUA + +// For Array.prototype.sort +export function basic_comparator(a: T, b: T) { + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } +} diff --git a/lib/compiler-finder.ts b/lib/compiler-finder.ts index 4a8c1ddd8..65e1b685a 100644 --- a/lib/compiler-finder.ts +++ b/lib/compiler-finder.ts @@ -41,7 +41,7 @@ import {logger} from './logger'; import {ClientOptionsHandler, OptionHandlerArguments} from './options-handler'; import {CompilerProps} from './properties'; import {PropertyGetter} from './properties.interfaces'; -import {remove} from './common-utils'; +import {basic_comparator, remove} from './common-utils'; const sleep = promisify(setTimeout); @@ -456,15 +456,7 @@ export class CompilerFinder { const result = this.ensureDistinct(compilers); return { foundClash: result.foundClash, - compilers: result.compilers.sort((a, b) => { - if (a.name < b.name) { - return -1; - } else if (a.name > b.name) { - return 1; - } else { - return 0; - } - }), + compilers: result.compilers.sort((a, b) => basic_comparator(a.name, b.name)), }; }