This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: wrap glob and minimatch to support windows paths
- Loading branch information
Showing
6 changed files
with
38 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { promisify } from 'util' | ||
|
||
import globFunction from 'glob' | ||
import minimatchFunction from 'minimatch' | ||
import unixify from 'unixify' | ||
|
||
const pGlob = promisify(globFunction) | ||
|
||
/** | ||
* Both glob and minimatch only support unix style slashes in patterns | ||
* For this reason we wrap them and ensure all patters are always unixified | ||
*/ | ||
|
||
export const glob = function (pattern: string, options: globFunction.IOptions): Promise<string[]> { | ||
let normalizedIgnore | ||
if (options.ignore) { | ||
normalizedIgnore = | ||
typeof options.ignore === 'string' | ||
? unixify(options.ignore) | ||
: options.ignore.map((expression) => unixify(expression)) | ||
} | ||
return pGlob(unixify(pattern), { ...options, ignore: normalizedIgnore }) | ||
} | ||
|
||
export const minimatch = function (target: string, pattern: string, options?: minimatchFunction.IOptions): boolean { | ||
return minimatchFunction(target, unixify(pattern), options) | ||
} |