Skip to content

Commit 40022f3

Browse files
committed
Improve Windows path documentation
Fixes #179
1 parent 1273541 commit 40022f3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

index.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ Find files and directories using glob patterns.
150150
151151
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
152152
153+
Windows: Patterns with backslashes will silently fail. Use `path.posix.join()` or `convertPathToPattern()`.
154+
153155
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). Supports negation patterns to exclude files. When using only negation patterns (like `['!*.json']`), globby implicitly prepends a catch-all pattern to match all files before applying negations.
154156
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
155157
@returns The matching paths.
@@ -296,7 +298,7 @@ export function isGitIgnored(options?: GitignoreOptions): Promise<GlobbyFilterFu
296298
export function isGitIgnoredSync(options?: GitignoreOptions): GlobbyFilterFunction;
297299

298300
/**
299-
Converts a path to a pattern by escaping special glob characters like `()`, `[]`, `{}`.
301+
Converts a path to a pattern by escaping special glob characters like `()`, `[]`, `{}`. On Windows, also converts backslashes to forward slashes.
300302
301303
Use this when your literal paths contain characters with special meaning in globs.
302304

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ console.log(paths);
4141

4242
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
4343

44+
**Windows:** Patterns with backslashes will silently fail. Use `path.posix.join()` or [`convertPathToPattern()`](#convertpathtopatternpath).
45+
4446
### globby(patterns, options?)
4547

4648
Returns a `Promise<string[]>` of matching paths.
@@ -131,7 +133,7 @@ for await (const path of globbyStream('*.tmp')) {
131133

132134
### convertPathToPattern(path)
133135

134-
Converts a path to a pattern by escaping special glob characters like `()`, `[]`, `{}`.
136+
Converts a path to a pattern by escaping special glob characters like `()`, `[]`, `{}`. On Windows, also converts backslashes to forward slashes.
135137

136138
Use this when your literal paths contain characters with special meaning in globs.
137139

0 commit comments

Comments
 (0)