Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Apr 14, 2023
1 parent a1cba4d commit aa91e5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm i glob
```

**Note** the npm package name is _not_ `node-glob` that's a
different thing that was abandoned years ago. Just `glob`.
different thing that was abandoned years ago. Just `glob`.

```js
// load using import
Expand Down Expand Up @@ -100,20 +100,20 @@ const groupReadableFiles = results
// you'll ignore all markdown files, and all folders named 'docs'
const customIgnoreResults = await glob('**', {
ignore: {
ignored: (p) => /\.md$/.test(p.name),
childrenIgnored: (p) => p.isNamed('docs'),
ignored: p => /\.md$/.test(p.name),
childrenIgnored: p => p.isNamed('docs'),
},
})

// another fun use case, only return files with the same name as
// their parent folder, plus either `.ts` or `.js`
const folderNamedModules = await glob('**/*.{ts,js}', {
ignore: {
ignored: (p) => {
ignored: p => {
const pp = p.parent
return !(p.isNamed(pp.name + '.ts') || p.isNamed(pp.name + '.js'))
}
}
},
},
})

// find all files edited in the last hour, to do this, we ignore
Expand All @@ -124,14 +124,14 @@ const newFiles = await glob('**', {
// only want the files, not the dirs
nodir: true,
ignore: {
ignored: (p) => {
return (new Date() - p.mtime) > (60 * 60 * 1000)
ignored: p => {
return new Date() - p.mtime > 60 * 60 * 1000
},
// could add similar childrenIgnored here as well, but
// directory mtime is inconsistent across platforms, so
// probably better not to, unless you know the system
// tracks this reliably.
}
},
})
```

Expand Down Expand Up @@ -431,7 +431,7 @@ share the previously loaded cache.
`absolute` may not be used along with `withFileTypes`.

- `posix` Set to true to use `/` as the path separator in
returned results. On posix systems, this has no effect. On
returned results. On posix systems, this has no effect. On
Windows systems, this will return `/` delimited path results,
and absolute paths will be returned in their full resolved UNC
path form, eg insted of `'C:\\foo\\bar'`, it will return
Expand Down
4 changes: 3 additions & 1 deletion test/memfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ for (const pattern of patterns) {
t.strictSame(await glob(pattern, { nodir: true, cwd }), ['/x'])
})
t.test('passing in fs argument', async t => {
t.strictSame(await glob(pattern, { nodir: true, cwd, fs }), ['/x'])
t.strictSame(await glob(pattern, { nodir: true, cwd, fs }), [
'/x',
])
})
})
}
Expand Down

0 comments on commit aa91e5c

Please sign in to comment.