Skip to content

Commit

Permalink
Merge 1c338bc into bc17b03
Browse files Browse the repository at this point in the history
  • Loading branch information
flops committed Dec 17, 2018
2 parents bc17b03 + 1c338bc commit d6d3dd7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/dependencies-builder/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ const buildNodes = async (

const dependencyAbsolutePath = resolveAbsolutePath(dependency, parentPath);

// Ignoring node modules
if (require.resolve.paths(dependencyAbsolutePath) === null) {
continue;
}

// Making link for already existing node
if (nodesCache[dependencyAbsolutePath]) {
resultNodes[dependency] = nodesCache[dependencyAbsolutePath];
Expand Down
8 changes: 3 additions & 5 deletions packages/fs-reader/src/file-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { IFile } from '@testring/types';

const ERR_NO_FILES = new Error('No test files found');

const isNotEmpty = (x: IFile | null): x is IFile => !!x;
const isNotEmpty = (x: IFile | null): x is IFile => x !== null;

export const readFile = (file: string): Promise<IFile | null> => {
const readPromise = new Promise<IFile>((resolve, reject) => {
return new Promise<IFile>((resolve, reject) => {
const filePath: string = path.resolve(file);

if (fs.existsSync(filePath)) {
Expand All @@ -25,16 +25,14 @@ export const readFile = (file: string): Promise<IFile | null> => {
reject(new Error(`File doesn't exist: ${filePath}`));
}
});

return readPromise.catch((error) => null);
};

export const resolveFiles = async (files: Array<string>): Promise<IFile[]> => {
if (!files || files.length === 0) {
throw ERR_NO_FILES;
}

const readFilePromises = files.map(readFile);
const readFilePromises = files.map(file => readFile(file).catch(() => null));
const filesContent = await Promise.all(readFilePromises);
const compacted = filesContent.filter(isNotEmpty);

Expand Down

0 comments on commit d6d3dd7

Please sign in to comment.