@rae004/get-file-paths
v0.1.8
Published
A package to get all file paths in a given directory recursively.
Downloads
4
Readme
Get File Paths
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
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
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
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'
}
]