Skip to content

Commit

Permalink
docs: updated changelog and added new badges in README
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciovigolo committed Apr 2, 2018
1 parent 26bf254 commit 142e898
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 58 deletions.
74 changes: 50 additions & 24 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,91 @@
<a name="1.3.0"></a>

# 1.3.0 (2017-04-02)

This release includes:

* Dependencies version update.
* Updated the project documentation.
* Fixed the parameter passed to micromatch as array.

<a name="1.2.0"></a>

# 1.2.0 (2017-03-14)

This release includes:

* PR's #3 and #2. Special thanks to @vindu939 and snyk.
* Changes in build script, including npx and shx (better os interoperability)

<a name="1.1.0"></a>

# 1.1.0 (2017-03-20)

Fix for issue #1 and documentation improvement.

<a name="1.0.0"></a>

# 1.0.0 (2017-01-02)

Official release milestone.


<a name="1.0.0-rc.7"></a>

# 1.0.0-rc.7 (2017-01-02)

Features
---
* ***contentMatch Event*** - changed to return the processed from percentage to ratio.
## Features

* **_contentMatch Event_** - changed to return the processed from percentage to ratio.

<a name="1.0.0-rc.6"></a>

# 1.0.0-rc.6 (2017-01-01)

Docs update


<a name="1.0.0-rc.5"></a>

# 1.0.0-rc.5 (2017-01-01)

Features
---
* ***Events***
- removed initSearchSubDirectory event as it has a duplicated meaning with preSearchDirectory event.
- removed endSearchSubDirectory from the docs list of available events to listen as it should be used more internally by the file-matcher API.
- Changed the return value from endSearchDirectory event. Now is returning the array of matched files (considering the first part of the search - before filtering by file content) and the total of files - number.
* ***Docs*** - Docs improvement.
## Features

* **_Events_**
* removed initSearchSubDirectory event as it has a duplicated meaning with preSearchDirectory event.
* removed endSearchSubDirectory from the docs list of available events to listen as it should be used more internally by the file-matcher API.
* Changed the return value from endSearchDirectory event. Now is returning the array of matched files (considering the first part of the search - before filtering by file content) and the total of files - number.
* **_Docs_** - Docs improvement.

Bug Fixes
---
* ***contentMatch Event*** - changed to return the processed as percentage and value change.
## Bug Fixes

* **_contentMatch Event_** - changed to return the processed as percentage and value change.

<a name="1.0.0-rc.4"></a>

# 1.0.0-rc.4 (2016-12-31)

Improving documentation and examples.


<a name="1.0.0-rc.3"></a>

# 1.0.0-rc.3 (2016-12-30)

Improving documentation.


<a name="1.0.0-rc.2"></a>

# 1.0.0-rc.2 (2016-12-30)

Features
---
* ***CI*** - Added Travis CI and coveralls.
## Features

* **_CI_** - Added Travis CI and coveralls.

<a name="1.0.0-rc.1"></a>

# 1.0.0-rc.1 (2016-12-30)

Migration from bitbucket to Github. First release as opensource project.

Features
---
* ***Dependencies change*** - removed async module dependency to start using async/await from typescript. Now the library has only one dependency - micromacth.
* ***Project status*** - coded, tested and production ready, however the version is RC for documenting purposes - to publish the library examples.
## Features

* **_Dependencies change_** - removed async module dependency to start using async/await from typescript. Now the library has only one dependency - micromacth.
* **_Project status_** - coded, tested and production ready, however the version is RC for documenting purposes - to publish the library examples.
67 changes: 33 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
file-matcher
=====================
Search files recursively using globs, file attributes and content match.
# file-matcher

Search files recursively using globs, file attributes and content match.

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![npm version](https://badge.fury.io/js/file-matcher.svg)](https://badge.fury.io/js/file-matcher)
[![Build Status](https://travis-ci.org/mauriciovigolo/file-matcher.svg?branch=master)](https://travis-ci.org/mauriciovigolo/file-matcher)
[![Coverage Status](https://coveralls.io/repos/github/mauriciovigolo/file-matcher/badge.svg?branch=master)](https://coveralls.io/github/mauriciovigolo/file-matcher?branch=master)
[![Join the chat at https://gitter.im/mauriciovigolo/file-matcher](https://img.shields.io/gitter/room/mauriciovigolo/file-matcher.svg)](https://gitter.im/mauriciovigolo/file-matcher?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Expand All @@ -21,15 +22,14 @@ Search files recursively using globs, file attributes and content match.
* [About](#about)
* [Installing](#installing)
* [Usage](#usage)
- [Ecmascript](#ecmascript)
- [Typescript](#typescript)
- [Examples](#examples)
* [Ecmascript](#ecmascript)
* [Typescript](#typescript)
* [Examples](#examples)
* [History](#history)
* [License](#license)

---


# About

This module offers assynchronous file search by filename, file attributes and content. The search could be recursive or not. The difference
Expand All @@ -38,58 +38,57 @@ for file contents, refining the search.

The result is a promise, resolved with an array of filenames that matched the criteria.


# Installing

```
$ npm i --save file-matcher
```

**Typescript projects:**.
1. No need to install an apart module for the typescript declarations files (ie.: @types/file-matcher),
as the source already bundles it's d.ts files.

2. Insert the following configuration inside the compilerOptions of the project's tsconfig.json file:
1. No need to install an apart module for the typescript declarations files (ie.: @types/file-matcher),
as the source already bundles it's d.ts files.

2. Insert the following configuration inside the compilerOptions of the project's tsconfig.json file:

``` json
```json
"compilerOptions": {
"lib": [
"es2015"
]
}
```
This will give support for promises and collections features without the need of an external library. This configuration is mandatory for Typescript projects.

This will give support for promises and collections features without the need of an external library. This configuration is mandatory for Typescript projects.

### Versions

Recommended to use in:
- Node >= 6
- Ecmascript >= 5
- Typescript >= 2.0.0

* Node >= 6
* Ecmascript >= 5
* Typescript >= 2.0.0

# Usage

The find function of filematcher provides the following search options:

* `path` - Path to be searched. ie: './lib/'
* `fileFilter` - options for filtering files, as:
- `fileNamePattern` - Glob pattern for looking for files - filenames. Example: ```['**/*.js'] ```
- `attributeFilters` - Array of filters - filter by file attributes like size, birth and modification dates. Example: ```js [{ type: AttributeType.Size, value: 10, operator: PredicateOperator.GreaterThan }] ```
- `content` - RegExp to validade file content, ie: ```/test/i ```
- `fileReadOptions` - These options will be used in the Node.JS `fs.ReadFile` function. So it has the same options as the original. Example: ```{ encoding:'utf8', flag: 'r' }```
* `path` - Path to be searched. ie: './lib/'
* `fileFilter` - options for filtering files, as:
* `fileNamePattern` - Glob pattern for looking for files - filenames. Example: `['**/*.js']`
* `attributeFilters` - Array of filters - filter by file attributes like size, birth and modification dates. Example: `js [{ type: AttributeType.Size, value: 10, operator: PredicateOperator.GreaterThan }]`
* `content` - RegExp to validade file content, ie: `/test/i`
* `fileReadOptions` - These options will be used in the Node.JS `fs.ReadFile` function. So it has the same options as the original. Example: `{ encoding:'utf8', flag: 'r' }`
* `recursiveSearch` - Tells the finder to search recursively from the given path. This is a boolean attribute, and the default value is false.

The next topics show a simple example on how to use the library in Ecmascript and Typescript.


## Ecmascript

The following search looks for .js files in the /home/user/prjs/ directory, that were
modified between 2016-12-23 and 2016-12-25, and content with "use strict".


``` javascript

```javascript
var fm = require('file-matcher');

var options = {
Expand Down Expand Up @@ -123,14 +122,12 @@ fileMatcher.find(options)
});
```


## Typescript

The same example, explained above - search to look for .js files in the /home/user/prjs/ directory, that were
modified between 2016-12-23 and 2016-12-25, and content must have "use strict". In Typescript it would be:


``` typescript
```typescript
import { FileMatcher, FindOptions, AttributeType, PredicateOperator } from 'file-matcher';

let options: FindOptions = {
Expand Down Expand Up @@ -162,32 +159,34 @@ fileMatcher.find(options)
.catch(error => {
// ...
});

```


## Events

The file-matcher module starts to look for files using the filename glob and filter attributes. The result of this search is a list with the matching files. The next step is to filter by file content, using the RegExp. If there isn't a RegExp to validate, then the library will return the list of files that were found initially.

During the file search, the following events are emitted:

### Events emmitted while filtering by filename and file attributes:

* `preSearchDirectory` - Emitted on before visiting the directory / subdirectories. Returns the directory.
* `endSearchDirectory` - Search by filename and file attributes was completed. Returns the list and the total of matched files, however be aware that this is not the final list of files if you are also searching for content match.

### Event emmitted while filtering by file content using the regex
* `contentMatch` - Regex matched. Returns the filename and the processed ratio (0 to 1).

* `contentMatch` - Regex matched. Returns the filename and the processed ratio (0 to 1).

## Examples

Checkout the [Github examples repo](https://github.com/mauriciovigolo/file-matcher-examples#README) or go strait to the examples:

* [Basic Search - Ecmascript](https://github.com/mauriciovigolo/file-matcher-examples/tree/master/basic-search-es);
* [Basic Search - Typescript](https://github.com/mauriciovigolo/file-matcher-examples/tree/master/basic-search-ts);
* [Search listening to the library events - Typescript](https://github.com/mauriciovigolo/file-matcher-examples/tree/master/events-search-ts);


# History
For the list of all changes see the [history log](CHANGELOG.md).

For the list of all changes see the [history log](CHANGELOG.md).

# License

Expand Down

0 comments on commit 142e898

Please sign in to comment.