From 284824c2cc3da600282e656a59818012220b2e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eloy=20Dur=C3=A1n?= Date: Fri, 3 Jan 2020 17:14:10 +0100 Subject: [PATCH] Cleanup more comments --- src/lib/definition-parser.ts | 13 ++++++++++--- src/parse-definitions.test.ts | 2 -- src/tester/test-runner.ts | 2 -- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lib/definition-parser.ts b/src/lib/definition-parser.ts index 05c40769..6cf2a9aa 100644 --- a/src/lib/definition-parser.ts +++ b/src/lib/definition-parser.ts @@ -107,6 +107,16 @@ function getTypesVersionsAndPackageJson(ls: ReadonlyArray): LsMinusTypes return { remainingLs, typesVersions, hasPackageJson: withoutPackageJson.length !== ls.length }; } +/** + * Parses a directory name into a version that either holds a single major version or a major and minor version. + * + * @example + * + * ```ts + * parseVersionFromDirectoryName("v1") // { major: 1 } + * parseVersionFromDirectoryName("v0.61") // { major: 0, minor: 61 } + * ``` + */ export function parseVersionFromDirectoryName(directoryName: string): TypingVersion | undefined { const match = /^v(\d+)(\.(\d+))?$/.exec(directoryName); if (match === null) { @@ -390,9 +400,6 @@ const nodeBuiltins: ReadonlySet = new Set([ "string_decoder", "timers", "tls", "tty", "url", "util", "v8", "vm", "zlib", ]); -// e.g. -// parseDependencyVersionFromPath("../../foo/v1", "foo") should return "{ major: 1 }" -// parseDependencyVersionFromPath("../../foo/v0.61", "foo") should return "{ major: 0, minor: 61 }" function parseDependencyVersionFromPath(packageName: string, dependencyName: string, dependencyPath: string): TypingVersion { const versionString = withoutStart(dependencyPath, `${dependencyName}/`); const version = versionString === undefined ? undefined : parseVersionFromDirectoryName(versionString); diff --git a/src/parse-definitions.test.ts b/src/parse-definitions.test.ts index 9a41f96a..b87d1278 100644 --- a/src/parse-definitions.test.ts +++ b/src/parse-definitions.test.ts @@ -17,8 +17,6 @@ testo({ // expect(defs.allPackages().length).toEqual(defs.allTypings().length + defs.allNotNeeded().length) // }, async mockParse() { - // console.log("waiting"); - // await new Promise(resolve => setTimeout(resolve, 5000)); const log = loggerWithErrors()[0]; const defs = await parseDefinitions(createMockDT().fs, undefined, log); expect(defs.allNotNeeded().length).toBe(1); diff --git a/src/tester/test-runner.ts b/src/tester/test-runner.ts index c331fcd1..13d95d3a 100644 --- a/src/tester/test-runner.ts +++ b/src/tester/test-runner.ts @@ -358,8 +358,6 @@ function getDependencyFromFile(file: string): PackageId | undefined { } if (subDirName) { - // TODO: - // Looks like "types/a/v3/c" const version = parseVersionFromDirectoryName(subDirName); if (version !== undefined) { return { name, version };