Skip to content

Commit

Permalink
v1.1.0 - support checking multiple paths at once
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Nov 16, 2023
1 parent d3aa83e commit f993a73
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# History

## v1.1.0 2023 November 16

- Support checking multiple paths at once

## v1.0.0 2023 November 16

- Consolidated out from [@bevry/file](https://github.com/bevry/file), [safefs](https://github.com/bevry/safefs), [boundation:fs.js](https://github.com/bevry/boundation/blob/HEAD/source/fs.js)
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bevry/fs-readable",
"version": "1.0.0",
"version": "1.1.0",
"description": "Check if a path is readable",
"homepage": "https://github.com/bevry/fs-readable",
"license": "Artistic-2.0",
Expand Down Expand Up @@ -145,7 +145,7 @@
}
},
"dependencies": {
"@bevry/fs-accessible": "^1.0.0",
"@bevry/fs-accessible": "^1.1.0",
"editions": "^6.13.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions source/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { accessible, isAccessible, R_OK } from '@bevry/fs-accessible'

/** Returns a Promise that rejects with an error if the path is not readable. */
export function readable(path: string): Promise<void> {
export function readable(path: string | Array<string>): Promise<void> {
return accessible(path, R_OK)
}

/** Returns a Promise that resolves to a boolean indicating if the path is readable or not. */
export function isReadable(path: string): Promise<boolean> {
export function isReadable(path: string | Array<string>): Promise<boolean> {
return isAccessible(path, R_OK)
}
6 changes: 6 additions & 0 deletions source/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ kava.suite('@bevry/fs-readable', function (suite, test) {
;(async function () {
equal(await isReadable(file), true, 'file is readable')
equal(await isReadable(dir), true, 'dir is readable')
equal(
await isReadable([file, dir]),
true,
'file and dir are both readable'
)
equal(await isReadable('missing'), false, 'missing file is not readable')
})()
.then(() => done())
Expand All @@ -20,6 +25,7 @@ kava.suite('@bevry/fs-readable', function (suite, test) {
;(async function () {
await readable(file)
await readable(dir)
await readable([file, dir])
})()
.then(() => done())
.catch((err: any) => done(err))
Expand Down

0 comments on commit f993a73

Please sign in to comment.