Skip to content

Commit

Permalink
fix(index.ts): fixed bug when passed invalid path
Browse files Browse the repository at this point in the history
On the scan and scanAsync functions, if a wrong path is passed now null is returned. Before there
was unexpected error
  • Loading branch information
euberdeveloper committed Dec 23, 2019
1 parent ddc6c8b commit b35c57c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
29 changes: 19 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dree",
"version": "2.4.3",
"version": "2.4.4",
"description": "A nodejs module wich helps you handle a directory tree providing you its abstraction through tested functions and a custom configuration.",
"main": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
Expand Down
8 changes: 6 additions & 2 deletions source/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,9 @@ export function scan(path: string, options?: ScanOptions, onFile?: Callback, onD
const root = resolve(path);
const opt = mergeScanOptions(options);
const result = _scan(root, root, 0, opt, onFile, onDir) as Dree;
result.sizeInBytes = result && opt.sizeInBytes ? result.sizeInBytes : undefined;
if (result) {
result.sizeInBytes = opt.sizeInBytes ? result.sizeInBytes : undefined;
}
return result;
}

Expand All @@ -858,7 +860,9 @@ export async function scanAsync(path: string, options?: ScanOptions, onFile?: Ca
const root = resolve(path);
const opt = mergeScanOptions(options);
const result = await _scanAsync(root, root, 0, opt, onFile, onDir) as Dree;
result.sizeInBytes = result && opt.sizeInBytes ? result.sizeInBytes : undefined;
if (result) {
result.sizeInBytes = opt.sizeInBytes ? result.sizeInBytes : undefined;
}
return result;
}

Expand Down

0 comments on commit b35c57c

Please sign in to comment.