Skip to content

Commit

Permalink
remove unnecessary import resolve error
Browse files Browse the repository at this point in the history
change to Promise.allSettled coz each https request has to be completed
loop to check if rejection then return promise reject false
lodash unneeded import by auto import removed
  • Loading branch information
king-11 committed Oct 5, 2020
1 parent 1cc3cb1 commit e809d95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/services/FileSystemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { IProjectFilesBrowserService, Metadata, MetadataType } from './model';
import { IFs, createFsFromVolume } from 'memfs';
import { Volume as VSVolume, DirectoryJSON } from 'memfs/lib/volume';
import { ErrorFactory } from '../lib/errors';
import { reject } from 'lodash';

/**
* Service for file system browsing
Expand Down
25 changes: 13 additions & 12 deletions src/services/git/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,21 @@ export class Git implements IProjectFilesBrowserService {

async flatTraverse(path: string, fn: (meta: Metadata) => void | boolean): Promise<void | boolean> {
const dirContent = await this.readDirectory(path);
const promises = dirContent.map(async (cnt) => {
const absolutePath = nodePath.posix.join(path, cnt);
const metadata = await this.getMetadata(absolutePath);

await Promise.all(
dirContent.map(async (cnt) => {
const absolutePath = nodePath.posix.join(path, cnt);
const metadata = await this.getMetadata(absolutePath);
const lambdaResult = fn(metadata);
if (lambdaResult === false) return Promise.reject(false);

const lambdaResult = fn(metadata);
if (lambdaResult === false) return Promise.reject(false);

if (metadata.type === MetadataType.dir) {
return this.flatTraverse(metadata.path, fn);
}
}),
);
if (metadata.type === MetadataType.dir) {
return this.flatTraverse(metadata.path, fn);
}
});
const status = await Promise.allSettled(promises);
if (status.some((e) => e.status === 'rejected')) {
return Promise.reject(false);
}
}

async getContributorCount(): Promise<number> {
Expand Down

0 comments on commit e809d95

Please sign in to comment.