Skip to content

Commit

Permalink
A few docs and test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bcomnes committed Dec 27, 2019
1 parent fcc3ab1 commit 85d434a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 7 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ name: tests
on: [push]

jobs:
build:

runs-on: ubuntu-latest
test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node-version: [12.x]
os: [ubuntu-latest, windows-latest, macos-latest]
node: [12]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test
node-version: ${{ matrix.node }}
- name: npm install && npm test
run: |
npm i
npm test
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,39 @@ The `shaper` function lets you change the shape of the returned value based on d
}
````

Example of a fwData object:

```js
{
root: '/Users/bret/repos/async-folder-walker/fixtures',
filepath: '/Users/bret/repos/async-folder-walker/fixtures/sub-folder/sub-sub-folder',
stat: Stats {
dev: 16777220,
mode: 16877,
nlink: 3,
uid: 501,
gid: 20,
rdev: 0,
blksize: 4096,
ino: 30244023,
size: 96,
blocks: 0,
atimeMs: 1574381262779.8396,
mtimeMs: 1574380914743.5474,
ctimeMs: 1574380914743.5474,
birthtimeMs: 1574380905232.5996,
atime: 2019-11-22T00:07:42.780Z,
mtime: 2019-11-22T00:01:54.744Z,
ctime: 2019-11-22T00:01:54.744Z,
birthtime: 2019-11-22T00:01:45.233Z
},
relname: 'sub-folder/sub-sub-folder',
basename: 'sub-sub-folder'
}
```

The `stat` property is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats) so it has extra methods not listed here.

### `files = await allFiles(paths, [opts])`

Get an Array of all files inside of a directory. `paths` can be a single string path or an array of string paths.
Expand Down
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ tap.test('Array from async iterator', async t => {
t.equal(files.length, 4, 'expected number of files are found')
})

tap.skip('Shape example', async t => {
await allFiles([fixtures], {
shaper: fwData => {
console.log(fwData)
return fwData
}
})
t.pass('shape printed')
})

tap.test('No args', async t => {
for await (const file of asyncFolderWalker()) {
t.fail(file, 'no files should be found!')
Expand Down

0 comments on commit 85d434a

Please sign in to comment.