@@ -26,6 +26,7 @@ import glob = require('glob');
26
26
import { autofix } from './autofix' ;
27
27
import { findConfigPath , loadConfig as resolveConfig } from './config' ;
28
28
import { NodeFileSystem } from './NodeFileSystem' ;
29
+ import { fileURLToPath } from 'node:url' ;
29
30
30
31
const asyncGlob = promisify ( glob ) ;
31
32
@@ -153,13 +154,29 @@ export async function getTheme(config: Config): Promise<Theme> {
153
154
// as mentioned in the documentation of node-glob
154
155
155
156
// the path is normalised and '\' are replaced with '/' and then passed to the glob function
156
- const normalizedGlob = path
157
- . normalize ( path . join ( config . rootUri . replace ( / ^ f i l e : / , '' ) , '**/*.{liquid,json}' ) )
158
- . replace ( / \\ / g, '/' ) ;
159
- const paths = await asyncGlob ( normalizedGlob ) . then ( ( result ) =>
157
+ let normalizedGlob = getThemeFilesPathPattern ( config . rootUri ) ;
158
+
159
+ const paths = await asyncGlob ( normalizedGlob , { absolute : true } ) . then ( ( result ) =>
160
160
// Global ignored paths should not be part of the theme
161
161
result . filter ( ( filePath ) => ! isIgnored ( filePath , config ) ) ,
162
162
) ;
163
163
const sourceCodes = await Promise . all ( paths . map ( toSourceCode ) ) ;
164
164
return sourceCodes . filter ( ( x ) : x is LiquidSourceCode | JSONSourceCode => x !== undefined ) ;
165
165
}
166
+
167
+ function getThemeFilesPathPattern ( rootUri : string ) {
168
+ let normalizedGlob = path
169
+ . normalize ( path . join ( fileURLToPath ( rootUri ) , '**/*.{liquid,json}' ) )
170
+ . replace ( / \\ / g, '/' ) ;
171
+
172
+ // The glob is always an absoluate path, so windows paths should always
173
+ // start with a drive letter (with few exceptions we can ignore).
174
+ // More info: https://learn.microsoft.com/en-us/dotnet/standard/io/file-path-formats
175
+ //
176
+ // If an absoluate path starts with a slash on Windows, we strip it
177
+ if ( process . platform === 'win32' && normalizedGlob . match ( / ^ \/ [ a - z A - Z ] : / ) ) {
178
+ normalizedGlob = normalizedGlob . slice ( 1 ) ;
179
+ }
180
+
181
+ return normalizedGlob ;
182
+ }
0 commit comments