Skip to content
This repository has been archived by the owner on Jun 11, 2020. It is now read-only.

Commit

Permalink
Cleanup more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Jan 7, 2020
1 parent 1cc0d83 commit 284824c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/lib/definition-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ function getTypesVersionsAndPackageJson(ls: ReadonlyArray<string>): 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) {
Expand Down Expand Up @@ -390,9 +400,6 @@ const nodeBuiltins: ReadonlySet<string> = 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);
Expand Down
2 changes: 0 additions & 2 deletions src/parse-definitions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/tester/test-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 284824c

Please sign in to comment.