https://github.com/lencx/deno-getfiles
📂 Recursively get all files in a directory
https://github.com/lencx/deno-getfiles
deno fileinfo fs getfiles
Last synced: 2 months ago
JSON representation
📂 Recursively get all files in a directory
- Host: GitHub
- URL: https://github.com/lencx/deno-getfiles
- Owner: lencx
- License: mit
- Created: 2020-06-14T06:18:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-10T14:22:21.000Z (almost 6 years ago)
- Last Synced: 2025-06-30T17:48:03.366Z (12 months ago)
- Topics: deno, fileinfo, fs, getfiles
- Language: TypeScript
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getFiles
> Recursively get all files in a directory
[](https://github.com/lencx/deno-getfiles/actions)

[](https://github.com/lencx/deno-getfiles/blob/master/LICENSE)
[](https://github.com/lencx)
## Usage
> needs --allow-read privilege
```ts
import getFiles, { exists, fileExt, trimPath, fmtFileSize } from "https://deno.land/x/getfiles/mod.ts";
// root path: './' or '.'
const files = getFiles('./');
// include files
const files2 = getFiles({
root: './',
include: ['examples'],
hasInfo: true,
// ignore: ['examples/include.ts'],
});
// exclude files
const files3 = getFiles({
root: './',
exclude: ['.git'],
// ignore: ['*.ts'],
});
// if a file exists
const existFile = await exists('mod.ts');
console.log(existFile);
```
## Methods
* [fs] - `getFiles`: default export
* [fs] - `findFile`
* [utils] - `exists`
* [utils] - `fileExt`: get file extensions
* [utils] - `trimPath`: trim path
* [utils] - `fmtFileSize`: converting file size in bytes to human readable string
* [utils] - `isStr`
## API
> getFiles
| Option | Type | Description | Example |
| ------- | -------- | ----------------------------- | ---------------------------------------------------------------- |
| root | string | directory | {root: '.'} |
| include | string[] | include directory | {root: '.', include: ['examples']} |
| exclude | string[] | exclude directory | {root: '.', exclude: ['.git']} |
| ignore | string[] | ignore file rule | {root: '.', ignore: ['\*.md', '\*\*/\*.ts', 'examples/tree.ts']} |
| hasInfo | boolean | file details, default `false` | {root: '.', hasInfo: true} |
## Examples
* [tree](./examples/tree.ts)
* [include](./examples/include.ts)
* [exclude](./examples/exclude.ts)
* [cmd](https://github.com/lencx/deno-example/blob/master/cmd.ts)