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

Explicitly exclude . and .. for fs.readdirSync #7676

Merged
merged 2 commits into from
Mar 24, 2016

Conversation

zhengbli
Copy link
Contributor

Fixes #7469

Exclude "." and ".." from the fs.readdir result explicitly due to the node bug that in some cases it fails to exclude these two items. (See microsoft/vscode#3860 and nodejs/node#4002)

const files = _fs.readdirSync(path || ".").sort();
// This filtering is necessary because on some file system node fails to exclude
// "." and "..". See https://github.com/nodejs/node/issues/4002
const files = filter(<string[]>_fs.readdirSync(path || "."), f => f !== "." && f !== "..").sort();
const directories: string[] = [];
for (const current of files) {
const name = combinePaths(path, current);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about if (current === "." || current === "..") continue; instead of the filter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better. Updated.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 24, 2016

👍

@zhengbli zhengbli merged commit 6cc1b17 into microsoft:master Mar 24, 2016
@zhengbli zhengbli deleted the fixNodeOnSharePoint branch March 24, 2016 23:08
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants