https://github.com/chrisyip/sagase
Searching files recursively.
https://github.com/chrisyip/sagase
Last synced: about 1 year ago
JSON representation
Searching files recursively.
- Host: GitHub
- URL: https://github.com/chrisyip/sagase
- Owner: chrisyip
- Created: 2014-04-22T15:00:58.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2017-09-11T13:54:37.000Z (almost 9 years ago)
- Last Synced: 2025-05-14T22:12:22.754Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sagase
[![NPM version][npm-image]][npm-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Travis CI][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]
Searching files recursively.
## Usage
### Command Line
```bash
npm install -g sagase
sagase path/to/search /pattern/ /exclude_pattern/
sagase -i path/to/search /pattern/ /exclude_pattern/
sagase -f path/to/search -p /pattern/ -x /exclude_pattern/
sagase --help
Options:
--folder, -f Path to search
--pattern, -p A regexp or string for matching file
--exclude, -x A regexp or string for excluding file
--excludeNameOnly, --exclude-nameonly Apply excluder on file name only
[boolean] [default: false]
--recursive, -r Search recursively
[boolean] [default: true]
--ignore-case, -i Ignore case [boolean] [default: false]
--version Show version number [boolean]
--help Show help [boolean]
```
### In Node.js
```bash
npm install --save sagase
```
```js
const { find } = require('sagase')
find({
folder: './',
pattern: /pattern/, // accept function, regexp or string
nameOnly: false,
exclude: /pattern/, // accept function, regexp or string
excludeNameOnly: false,
recursive: true
})
.then(files => {})
// `pattern` and `exclude` accept [Function]
// in this case, `nameOnly` and `excludeNameOnly` will be ignored
find({
folder: './',
pattern (name, path) {
return true // to mark as matched
},
exclude (name, path) {
return true // to mark as excluded
}
})
.then(files => {})
// Synchronous `find`
const { findSync } = require('sagase')
const files = findSync(options)
```
### Available Options
`-f`, `--folder`: Path to search.
`-p`, `--pattern`: A regexp or string for matching file.
`--name-only`: Only apply `pattern` on **filename**.
`-x`, `--exclude`: A regexp or string for excluding file.
`--exclude-nameonly`: Only apply `exclude` on **filename**.
`-i`, `--ignore-case`: Should ignore case.
`-r`, `--recursive`: Search recursively.
## License
Licensed under the MIT license.
[npm-url]: https://npmjs.org/package/sagase
[npm-image]: http://img.shields.io/npm/v/sagase.svg?style=flat-square
[daviddm-url]: https://david-dm.org/chrisyip/sagase
[daviddm-image]: http://img.shields.io/david/chrisyip/sagase.svg?style=flat-square
[travis-url]: https://travis-ci.org/chrisyip/sagase
[travis-image]: http://img.shields.io/travis/chrisyip/sagase.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/chrisyip/sagase
[codecov-image]: https://img.shields.io/codecov/c/github/chrisyip/sagase.svg?style=flat-square