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

Need help debugging an issue?? with fdir #73

Closed
glenn2223 opened this issue Jan 14, 2022 · 4 comments
Closed

Need help debugging an issue?? with fdir #73

glenn2223 opened this issue Jan 14, 2022 · 4 comments

Comments

@glenn2223
Copy link

I've had an issue opened over on a repo - glenn2223/vscode-live-sass-compiler#145

I can't for the life of me figure out why fdir has returned a file count of 0 when the filters applied all return true for one file

They have an SSH connection in VS Code but I don't see why that would be a problem


I have copied out a section of code that produces the below output (copied from this comment)

Code

const isMatch = picomatch(fileList, { ignore: excludeItems, dot: true, nocase: true });

OutputWindow.Show(OutputLevel.Trace, "Searching folder", null, false);

const searchLogs: Map<string, string[]> = new Map<string, string[]>();

const searchFileCount = (
    (await new fdir()
        .crawlWithOptions(basePath, {
            filters: [
                (filePath) =>
                    filePath.toLowerCase().endsWith(".scss") ||
                    filePath.toLowerCase().endsWith(".sass"),
                (filePath) => {
                    const result = isMatch(path.relative(basePath, filePath));

                    searchLogs.set(`Path: ${filePath}`, [
                        `  isMatch: ${result}`,
                        `   - Base path: ${basePath}`,
                        `   - Rela path: ${path.relative(basePath, filePath)}`,
                    ]);

                    return result;
                },
                (filePath) => {
                    const result =
                        path
                            .toNamespacedPath(filePath)
                            .localeCompare(path.toNamespacedPath(sassPath), undefined, {
                                sensitivity: "accent",
                            }) === 0;

                    searchLogs
                        .get(`Path: ${filePath}`)
                        ?.push(
                            `  compare: ${result}`,
                            `   - Orig file path: ${filePath}`,
                            `   - Orig sass path: ${sassPath}`
                        );

                    return result;
                },
            ],
            includeBasePath: true,
            onlyCounts: true,
            resolvePaths: true,
            suppressErrors: true,
        })
        .withPromise()) as OnlyCountsOutput
).files;

const x = await new fdir()
    .crawlWithOptions(basePath, {
        includeBasePath: true,
        group: true,
        resolvePaths: true,
        suppressErrors: true,
    })
    .withPromise();

OutputWindow.Show(OutputLevel.Trace, "FDIR OUTPUT", [JSON.stringify(x)]);

OutputWindow.Show(OutputLevel.Trace, "Search results", undefined, false);

searchLogs.forEach((logs, key) => {
    OutputWindow.Show(OutputLevel.Trace, key, logs, false);
});

And here is the section from the output

Searching folder
FDIR OUTPUT
[
   {
      "dir":"/home/dave/MagentoAPI",
      "files":[ ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev",
      "files":[
         "/home/dave/MagentoAPI/dev/docker-compose.yml",
         "/home/dave/MagentoAPI/dev/dockerfile"
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/.app",
      "files":[
         "/home/dave/MagentoAPI/dev/.app/composer.json",
         "/home/dave/MagentoAPI/dev/.app/composer.lock"
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/.vscode",
      "files":[
         "/home/dave/MagentoAPI/dev/.vscode/settings.json"
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/mysql-data",
      "files":[
         /// Bunch of SQL files removed for brevity
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/php-confs",
      "files":[
         "/home/dave/MagentoAPI/dev/php-confs/override.ini"
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/src",
      "files":[
         /// Bunch of PHP files removed for brevity
         "/home/dave/MagentoAPI/dev/src/AttributesSamplePayload.json",
         "/home/dave/MagentoAPI/dev/src/MageAPIdev.code-workspace",
         "/home/dave/MagentoAPI/dev/src/newfile.txt",
         "/home/dave/MagentoAPI/dev/src/style.css",
         "/home/dave/MagentoAPI/dev/src/workspace.code-workspace"
      ]
   },
   {
      "dir":"/home/dave/MagentoAPI/dev/.app/vendor",
      "files":[
         "/home/dave/MagentoAPI/dev/.app/vendor/autoload.php"
      ]
   }
]
--------------------
Search results
Path: /home/dave/MagentoAPI/dev/src/styles/main.scss
  isMatch: true
   - Base path: /home/dave/MagentoAPI
   - Rela path: dev/src/styles/main.scss
  compare: true
   - Orig file path: /home/dave/MagentoAPI/dev/src/styles/main.scss
   - Orig sass path: /home/dave/MagentoAPI/dev/src/styles/main.scss
@thecodrr
Copy link
Owner

I am taking a look at this. Hold on.

@thecodrr
Copy link
Owner

@glenn2223 can you try this again with v5.2.0?

@glenn2223
Copy link
Author

Thanks for working on this and turning it around so quickly!

I have asked the individual to test this release and get back to me

Report back soon with good news I hope 🤞

@glenn2223
Copy link
Author

They have confirmed that it's fixed in v5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants