Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(readdirSync): 🐛 Error no such file or directory #348

Merged
merged 1 commit into from
Dec 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/__tests__/union.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,32 @@ describe('union', () => {
ufs.use(vol2 as any);
expect(ufs.readdirSync("/foo")).toEqual(["bar", "baz", "qux"]);
});

it("reads other fss when one fails", () => {
const vol = Volume.fromJSON({
"/foo/bar": "bar",
"/foo/baz": "baz"
});
const vol2 = Volume.fromJSON({
"/bar/baz": "not baz",
"/bar/qux": "baz"
});

const ufs = new Union();
ufs.use(vol as any);
ufs.use(vol2 as any);
expect(ufs.readdirSync("/bar")).toEqual(["baz", "qux"]);
});

it("throws error when all fss fail", () => {
const vol = Volume.fromJSON({});
const vol2 = Volume.fromJSON({});

const ufs = new Union();
ufs.use(vol as any);
ufs.use(vol2 as any);
expect(() => ufs.readdirSync("/bar")).toThrow();
});
});
});
describe('async methods', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/union.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class Union {
} catch(err) {
err.prev = lastError;
lastError = err;
if(!i) { // last one
if(result.size === 0 && !i) { // last one
throw err;
} else {
// Ignore error...
Expand Down