Skip to content

Commit

Permalink
Implement expandGlob() and expandGlobSync() (denoland/std#617)
Browse files Browse the repository at this point in the history
fs/glob.ts:
- Improve prototypes for expandGlob() and expandGlobSync() from denoland/std#604.
- Rename glob() to globToRegExp().
- Add normalizeGlob() and joinGlobs().
- Extract GlobToRegExpOptions from GlobOptions, remove the strict
  and filepath options.

fs/globrex.ts:
- Add GlobrexOptions.

fs/path/constants.ts:
- Add SEP_PATTERN.

fs/walk.ts:
- Add WalkOptions::includeFiles
- Default WalkOptions::includeDirs to true.
- Don't traverse directories matching a skip pattern.
- Remove walkSync()'s default root value.

prettier:
- Refactor to use expandGlob().

testing:
- Make findTestModules() an async generator.
Original: denoland/std@8c90bd9
  • Loading branch information
nayeemrmn authored and ry committed Oct 2, 2019
1 parent aca2253 commit 2f90225
Show file tree
Hide file tree
Showing 11 changed files with 557 additions and 272 deletions.
4 changes: 2 additions & 2 deletions format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ async function main(opts): Promise<void> {
"--ignore",
"node_modules",
"--ignore",
"testdata",
"**/testdata",
"--ignore",
"vendor",
"**/vendor",
"--write"
];

Expand Down
8 changes: 4 additions & 4 deletions fs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ exists("./foo"); // returns a Promise<boolean>
existsSync("./foo"); // returns boolean
```

### glob
### globToRegExp

Generate a regex based on glob pattern and options
This was meant to be using the the `fs.walk` function
but can be used anywhere else.

```ts
import { glob } from "https://deno.land/std/fs/mod.ts";
import { globToRegExp } from "https://deno.land/std/fs/mod.ts";

glob("foo/**/*.json", {
globToRegExp("foo/**/*.json", {
flags: "g",
extended: true,
globstar: true
Expand Down Expand Up @@ -160,7 +160,7 @@ Iterate all files in a directory recursively.
```ts
import { walk, walkSync } from "https://deno.land/std/fs/mod.ts";

for (const fileInfo of walkSync()) {
for (const fileInfo of walkSync(".")) {
console.log(fileInfo.filename);
}

Expand Down
Loading

0 comments on commit 2f90225

Please sign in to comment.