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 realPathMap in test harness: Must be used in directoryExists #11957

Merged
2 commits merged into from
Oct 31, 2016

Conversation

ghost
Copy link

@ghost ghost commented Oct 31, 2016

Test originally added by #8486
Was broken during a merge commit #9169

let exists = false;
fileMap.forEachValue(key => {
if (key.indexOf(path) === 0 && key[path.length] === "/") {
fileMap.forEachValue(fileName => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we instead have a function

function mapHasFileInDirectory(path: Path, map: FileMap<any>): boolean {
    if (!map) {
        return false;
    }
    let exists = false;
    map.forEachValue(fileName => {
        if (!exists && startsWith(fileName, path) && fileName[path.length] === "/") {
            exists = true;
        }
    });
    return exists;
}

then original code can be rewritten as

const exists  = mapHasFileInDirectory(path, fileMap) || mapHasFileInDirectory(path, realPathMap);

@ghost ghost merged commit 49be2e2 into master Oct 31, 2016
@ghost ghost deleted the fix_realpathmap branch October 31, 2016 21:03
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
This pull request was closed.
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.

2 participants