From ad792ccb7dcb4f94f725474148e5cb935bc25811 Mon Sep 17 00:00:00 2001 From: Jeremy <51220084+jeremy-rifkin@users.noreply.github.com> Date: Fri, 2 Dec 2022 18:24:12 -0500 Subject: [PATCH] Address review comments --- lib/compiler-finder.ts | 16 ++++++++-------- lib/properties.ts | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/compiler-finder.ts b/lib/compiler-finder.ts index 29fe8b321..332842441 100644 --- a/lib/compiler-finder.ts +++ b/lib/compiler-finder.ts @@ -27,17 +27,19 @@ import https from 'https'; import path from 'path'; import {promisify} from 'util'; +import AWS from 'aws-sdk'; import fs from 'fs-extra'; import _ from 'underscore'; import urljoin from 'url-join'; +import {Language} from '../types/languages.interfaces'; + import {InstanceFetcher} from './aws'; +import {CompileHandler} from './handlers/compile'; import {logger} from './logger'; -import {PropertyGetter, PropertyValue, Widen} from './properties.interfaces'; -import {CompilerProps, RawPropertiesGetter} from './properties'; -import AWS from 'aws-sdk'; import {ClientOptionsHandler} from './options-handler'; -import {CompileHandler} from './handlers/compile'; +import {CompilerProps, RawPropertiesGetter} from './properties'; +import {PropertyGetter, PropertyValue, Widen} from './properties.interfaces'; const sleep = promisify(setTimeout); @@ -64,7 +66,7 @@ export class CompilerFinder { awsProps: PropertyGetter; args: CompilerFinderArguments; compileHandler: CompileHandler; - languages: Record<string, any>; + languages: Record<string, Language>; awsPoller: InstanceFetcher | null = null; optionsHandler: ClientOptionsHandler; @@ -349,7 +351,6 @@ export class CompilerFinder { } return this.compilerProps(langId, `group.${groupName}.${name}`, parentProps(langId, name, def)); }; - // TODO: Eliminate this cast const exes = _.compact(this.compilerProps(langId, `group.${groupName}.compilers`, '').split(':')); logger.debug(`Processing compilers from group ${groupName}`); return Promise.all(exes.map(compiler => this.recurseGetCompilers(langId, compiler, props))); @@ -412,8 +413,7 @@ export class CompilerFinder { } addNdkExes(langToCompilers) { - // TODO: Fix types here - const ndkPaths = this.compilerProps(this.languages, 'androidNdk') as unknown as _.Dictionary<any>; + const ndkPaths = this.compilerProps(this.languages, 'androidNdk') as unknown as Record<string, string>; _.each(ndkPaths, (ndkPath, langId) => { if (ndkPath) { const toolchains = fs.readdirSync(`${ndkPath}/toolchains`); diff --git a/lib/properties.ts b/lib/properties.ts index 995672696..6dbb8c299 100644 --- a/lib/properties.ts +++ b/lib/properties.ts @@ -213,21 +213,21 @@ export class CompilerProps { defaultValue?: PropertyValue, fn?: (item: PropertyValue, language?: any) => unknown, ) { - fn = fn || _.identity; + const map_fn = fn || _.identity; if (_.isEmpty(langs)) { - return fn(this.ceProps(key, defaultValue)); + return map_fn(this.ceProps(key, defaultValue)); } if (!_.isString(langs)) { return _.chain(langs) - .map(lang => [lang.id, fn!(this.$getInternal(lang.id, key, defaultValue), lang)]) + .map(lang => [lang.id, map_fn(this.$getInternal(lang.id, key, defaultValue), lang)]) .object() .value(); } else { if (this.propsByLangId[langs]) { - return fn(this.$getInternal(langs, key, defaultValue), this.languages[langs]); + return map_fn(this.$getInternal(langs, key, defaultValue), this.languages[langs]); } else { logger.error(`Tried to pass ${langs} as a language ID`); - return fn(defaultValue); + return map_fn(defaultValue); } } } -- GitLab