'glob paths don't work in my Windows environment

I don't know what happened, suddenly, all my applications that make use of glob paths broke.

Jasmine, TypeORM, any library I need to specify directories through of glob patterns don't work on my Windows.

I dove deeply into those libraries trying to solve the issue. I figured out that libraries use some path module's functions, like join and normalize, to handle the paths before passing them to the glob module. Let me show a code snippet from Jasmine library:

 includeFiles.forEach(function(file) {
      if(!(path.isAbsolute && path.isAbsolute(file))) {
        file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file);
      }
      
      var filePaths = glob.sync(file, { ignore: excludeFiles });

C:\Users\User\Programmation\project\test***[sS]pec.js

The join function converts all slashes from path to backslashes, but the glob module doesn't recognize paths with backslashes. The same thing happens with TypeORM using the normalize function from the path module under the hood.

const allFiles = directories.reduce((allDirs, dir) => {

        return allDirs.concat(glob_1.default.sync(PlatformTools_1.PlatformTools.pathNormalize(dir)));
    }, []);

The curious thing is that everything has worked before. I don't know exactly when it stopped working, but it did.



Solution 1:[1]

I encountered a similar problem.

After digging inside the TypeORM code I realized the problem is with the glob library.

glob has a problem with the windows separator. I ended up replacing the separator like this:

entities: [
   (__dirname+"\\..\\entities\\**\\*.entity{.ts,.js}").replace(/\\/g,'/')
],

Solution 2:[2]

When we GROUP BY country_id, we produce a result of rows, one per country.

The aggregate COUNT will then operate on one group for each country and the subsequent window function (LAG) won't see more than one row for each country.

There's no way, in this context, LAG can be used to obtain data for a prior month for the same country.

GROUP BY country_id, date_part('month', order_date) is one approach that could be used. Be sure to LAG OVER PARTITIONs for each country, ordered by date.

Here's a small change in your SQL that might help (not tested and just a starting point).

Note: I used SQL Server to test below. Convert datepart to date_part as needed.

Fiddle for SQL Server

WITH cte AS (
        SELECT *, datepart(month, order_date) AS mnth
          FROM orders
         WHERE order_date >= DATEADD(DAY, -90, GETDATE())
     )
SELECT mnth
     , country_id
     , 100 * (COUNT(*) - LAG(COUNT(*)) OVER (PARTITION BY country_id ORDER BY mnth)) / LAG(COUNT(*)) OVER (PARTITION BY country_id ORDER BY mnth) AS growth
  FROM cte
 GROUP BY country_id, mnth
;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yonatan Naor
Solution 2