@rae004/get-file-paths
Version:
A package to get all file paths in a given directory recursively.
76 lines (62 loc) • 1.8 kB
Markdown
# Get File Paths
[](https://www.npmjs.org/package/@rae004/get-file-paths) [](https://github.com/rae004/get-file-paths/blob/main/LICENSE) 
[//]: # ()
# Install
### npm
`npm i @rae004/get-file-paths`
### yarn
`yarn add @rae004/get-file-paths`
# Basic Usage
## Get All files in directory with default options
```typescript
import { getFilePaths } from '@rae004/get-file-paths';
const paths = await getFilePaths('./')
```
### output:
```
[
{
fullPath: '/Users/daUser/projects/get-file-paths/package.json',
relativePath: 'Users/daUser/projects/get-file-paths/package.json',
fileName: 'package.json'
}
// ...Other File objects
]
```
## Get All files with a relative root of projects
### don't include relative root in relativePath
```typescript
import { getFilePaths } from '@rae004/get-file-paths';
const paths = await getFilePaths('./', {
relativeRoot: 'projects',
includeRelativeRoot: false
})
```
### output:
```
[
{
fullPath: '/Users/rae004/projects/get-file-paths/package.json',
relativePath: 'get-file-paths/package.json',
fileName: 'package.json'
}
]
```
### include relative root in relativePath
```typescript
import { getFilePaths } from '@rae004/get-file-paths';
const paths = await getFilePaths('./', {
relativeRoot: 'projects',
includeRelativeRoot: true
})
```
### output:
```
[
{
fullPath: '/Users/rae004/projects/get-file-paths/package.json',
relativePath: 'get-file-paths/package.json',
fileName: 'package.json'
}
]
```