Skip to content

Commit

Permalink
Merge pull request #339 from jprichardson/rm-walk
Browse files Browse the repository at this point in the history
Remove walk() & walkSync()
  • Loading branch information
jprichardson committed Jan 3, 2017
2 parents cc1aaa9 + 1f83cb0 commit de1d483
Show file tree
Hide file tree
Showing 11 changed files with 2 additions and 227 deletions.
61 changes: 0 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,65 +403,6 @@ fs.remove('/tmp/myfile', function (err) {
fs.removeSync('/home/jprichardson') //I just deleted my entire HOME directory.
```

### walk()

**walk(dir, [streamOptions])**

The function `walk()` from the module [`klaw`](https://github.com/jprichardson/node-klaw).

Returns a [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable) that iterates
through every file and directory starting with `dir` as the root. Every `read()` or `data` event
returns an object with two properties: `path` and `stats`. `path` is the full path of the file and
`stats` is an instance of [fs.Stats](https://nodejs.org/api/fs.html#fs_class_fs_stats).

Streams 1 (push) example:

```js
var fs = require('fs-extra')
var items = [] // files, directories, symlinks, etc
fs.walk(TEST_DIR)
.on('data', function (item) {
items.push(item.path)
})
.on('end', function () {
console.dir(items) // => [ ... array of files]
})
```

Streams 2 & 3 (pull) example:

```js
var items = [] // files, directories, symlinks, etc
var fs = require('fs-extra')
fs.walk(TEST_DIR)
.on('readable', function () {
var item
while ((item = this.read())) {
items.push(item.path)
}
})
.on('end', function () {
console.dir(items) // => [ ... array of files]
})
```

If you're not sure of the differences on Node.js streams 1, 2, 3 then I'd
recommend this resource as a good starting point: https://strongloop.com/strongblog/whats-new-io-js-beta-streams3/.

**See [`klaw` documentation](https://github.com/jprichardson/node-klaw) for more detailed usage.**

### walkSync(dir)

Lists all files inside a directory recursively

Examples:

```js
var fs = require('fs-extra')

var files = fs.walkSync('/home/jprichardson')
// files = ['/home/jprichardson/file1', '/home/jprichardson/dir1/file2']
```

### writeJson(file, object, [options], callback)

Expand Down Expand Up @@ -527,8 +468,6 @@ What's needed?
- First, take a look at existing issues. Those are probably going to be where the priority lies.
- More tests for edge cases. Specifically on different platforms. There can never be enough tests.
- Improve test coverage. See coveralls output for more info.
- After the directory walker is integrated, any function that needs to traverse directories like
`copy`, `remove`, or `mkdirs` should be built on top of it.

Note: If you make any big changes, **you should definitely file an issue for discussion first.**

Expand Down
2 changes: 0 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ assign(fs, require('./move'))
assign(fs, require('./empty'))
assign(fs, require('./ensure'))
assign(fs, require('./output'))
assign(fs, require('./walk'))
assign(fs, require('./walk-sync'))

module.exports = fs

Expand Down
Empty file.
Empty file.
Empty file.
55 changes: 0 additions & 55 deletions lib/walk-sync/__tests__/walkSync.test.js

This file was deleted.

22 changes: 0 additions & 22 deletions lib/walk-sync/index.js

This file was deleted.

7 changes: 0 additions & 7 deletions lib/walk/__tests__/fixtures.json

This file was deleted.

73 changes: 0 additions & 73 deletions lib/walk/__tests__/walk.test.js

This file was deleted.

5 changes: 0 additions & 5 deletions lib/walk/index.js

This file was deleted.

4 changes: 2 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var os = require('os')
var path = require('path')
var Mocha = require('mocha')
var assign = require('./lib/util/assign')
var fs = require('./')
var klaw = require('klaw')

var argv = require('minimist')(process.argv.slice(2))

Expand All @@ -14,7 +14,7 @@ var mochaOpts = assign({

var mocha = new Mocha(mochaOpts)

fs.walk('./lib').on('readable', function () {
klaw('./lib').on('readable', function () {
var item
while ((item = this.read())) {
if (!item.stats.isFile()) return
Expand Down

0 comments on commit de1d483

Please sign in to comment.