filehound 1.17.3 → 1.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -421,8 +421,22 @@ class FileHound extends EventEmitter {
421
421
  }
422
422
 
423
423
  /**
424
- * Same as glob
425
- * @see glob
424
+ * Filter by a file glob
425
+ *
426
+ * @memberOf FileHound
427
+ * @instance
428
+ * @method
429
+ * match
430
+ * @param {array} glob - array of globs
431
+ * @return a FileHound instance
432
+ * @example
433
+ * import FileHound from 'filehound';
434
+ *
435
+ * const filehound = FileHound.create();
436
+ * filehound
437
+ * .match(['*tmp*']) // .match('*tmp*')
438
+ * .find()
439
+ * .each(console.log); // array of files names all containing 'tmp'
426
440
  */
427
441
  match(globPatterns) {
428
442
  if (_.isArray(globPatterns)) {
@@ -727,6 +741,7 @@ class FileHound extends EventEmitter {
727
741
  let isDir = false;
728
742
  try {
729
743
  isDir = file.isDirectorySync();
744
+ // eslint-disable-next-line no-empty
730
745
  } catch (e) { }
731
746
 
732
747
  if (isDir) {
@@ -744,7 +759,7 @@ class FileHound extends EventEmitter {
744
759
  return {
745
760
  path: file.getName(),
746
761
  stats: file._getStatsSync()
747
- }
762
+ };
748
763
  }
749
764
  return file.getName();
750
765
  }
@@ -769,7 +784,7 @@ export default FileHound;
769
784
  <br class="clear">
770
785
 
771
786
  <footer>
772
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Jan 28 2019 16:48:23 GMT+0000 (GMT) using the Minami theme.
787
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Wed Aug 05 2020 13:26:06 GMT+0200 (Central European Summer Time) using the Minami theme.
773
788
  </footer>
774
789
 
775
790
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -48,11 +48,13 @@
48
48
 
49
49
 
50
50
  <section class="readme">
51
- <article><h1>Filehound</h1><p><a href="https://travis-ci.org/nspragg/filehound"><img src="https://travis-ci.org/nspragg/filehound.svg" alt="Build Status"></a> <a href="https://coveralls.io/github/nspragg/filehound?branch=master"><img src="https://coveralls.io/repos/github/nspragg/filehound/badge.svg?branch=master" alt="Coverage Status"></a></p>
51
+ <article><h1>Filehound</h1>
52
+ <p><a href="https://travis-ci.org/nspragg/filehound"><img src="https://travis-ci.org/nspragg/filehound.svg" alt="Build Status"></a> <a href="https://coveralls.io/github/nspragg/filehound?branch=master"><img src="https://coveralls.io/repos/github/nspragg/filehound/badge.svg?branch=master" alt="Coverage Status"></a></p>
52
53
  <blockquote>
53
54
  <p>Flexible and fluent interface for searching the file system</p>
54
55
  </blockquote>
55
- <h2>Common examples</h2><p>The example below prints all of the files in a directory that have the <code>.json</code> file extension:</p>
56
+ <h2>Common examples</h2>
57
+ <p>The example below prints all of the files in a directory that have the <code>.json</code> file extension:</p>
56
58
  <pre class="prettyprint source lang-js"><code>const FileHound = require('filehound');
57
59
 
58
60
  const files = FileHound.create()
@@ -60,11 +62,17 @@ const files = FileHound.create()
60
62
  .ext('json')
61
63
  .find();
62
64
 
63
- files.then(console.log);</code></pre><h4>Matching the filename</h4><p>Find all the files that start with <code>dev</code>:</p>
65
+ files.then(console.log);
66
+ </code></pre>
67
+ <h4>Matching the filename</h4>
68
+ <p>Find all the files that start with <code>dev</code>:</p>
64
69
  <pre class="prettyprint source lang-js"><code>const files = FileHound.create()
65
70
  .paths('/etc/pki/')
66
71
  .match('dev*')
67
- .find();</code></pre><h4>Filtering by file size</h4><p>Find all of the files in a directory that are larger than 1024 bytes:</p>
72
+ .find();
73
+ </code></pre>
74
+ <h4>Filtering by file size</h4>
75
+ <p>Find all of the files in a directory that are larger than 1024 bytes:</p>
68
76
  <pre class="prettyprint source lang-js"><code>const files = FileHound.create()
69
77
  .paths('/some/dir')
70
78
  .size('>1024')
@@ -73,20 +81,32 @@ files.then(console.log);</code></pre><h4>Matching the filename</h4><p>Find all t
73
81
  const files = FileHound.create()
74
82
  .paths('/some/dir')
75
83
  .size('&lt;=1mb')
76
- .find();</code></pre><h4>Combining filters</h4><p>Find all the <code>.txt</code> files that are larger than 1024 bytes <em>and</em> start with <code>note</code>:</p>
84
+ .find();
85
+ </code></pre>
86
+ <h4>Combining filters</h4>
87
+ <p>Find all the <code>.txt</code> files that are larger than 1024 bytes <em>and</em> start with <code>note</code>:</p>
77
88
  <pre class="prettyprint source lang-js"><code>const files = FileHound.create()
78
89
  .paths('/etc/pki/')
79
90
  .match('note*')
80
91
  .ext('txt')
81
92
  .size('>1024')
82
- .find();</code></pre><h4>Inverse filtering</h4><p>Find all of the files that <em>don't</em> have the <code>.json</code> extension:</p>
93
+ .find();
94
+ </code></pre>
95
+ <h4>Inverse filtering</h4>
96
+ <p>Find all of the files that <em>don't</em> have the <code>.json</code> extension:</p>
83
97
  <pre class="prettyprint source lang-js"><code>const files = FileHound.create()
84
98
  .ext('json')
85
99
  .not()
86
- .find();</code></pre><h4>Limiting the depth of a recursive search</h4><p>Find all files but <em>only</em> in the current directory (recursion off):</p>
100
+ .find();
101
+ </code></pre>
102
+ <h4>Limiting the depth of a recursive search</h4>
103
+ <p>Find all files but <em>only</em> in the current directory (recursion off):</p>
87
104
  <pre class="prettyprint source lang-js"><code>const files = FileHound.create()
88
105
  .depth(0)
89
- .find();</code></pre><h4>Combining multiple searches</h4><p>Find all the files that are <em>either</em> over 1K _or_ have the <code>.json</code> file extension:</p>
106
+ .find();
107
+ </code></pre>
108
+ <h4>Combining multiple searches</h4>
109
+ <p>Find all the files that are <em>either</em> over 1K <em>or</em> have the <code>.json</code> file extension:</p>
90
110
  <pre class="prettyprint source lang-js"><code>const filesOverOneK = FileHound.create()
91
111
  .paths('/some/dir')
92
112
  .size('>1k')
@@ -97,7 +117,10 @@ const jsonFiles = FileHound.create()
97
117
  .ext('json')
98
118
  .find();
99
119
 
100
- const files = FileHound.any(filesOverOneK, jsonFiles);</code></pre><h4>Defining multiple search locations</h4><p>Find all JSON files in '/some/dir1' and '/some/dir2'</p>
120
+ const files = FileHound.any(filesOverOneK, jsonFiles);
121
+ </code></pre>
122
+ <h4>Defining multiple search locations</h4>
123
+ <p>Find all JSON files in '/some/dir1' and '/some/dir2'</p>
101
124
  <pre class="prettyprint source lang-js"><code>const jsonFiles = FileHound.create()
102
125
  .paths('/some/dir1', '/some/dir2')
103
126
  .ext('json')
@@ -107,25 +130,37 @@ const myPaths = ['/some/dir1', '/some/dir2'];
107
130
  const jsonFiles = FileHound.create()
108
131
  .paths(myPaths)
109
132
  .ext('json')
110
- .find();</code></pre><h4>Search synchronously</h4><p>Find all JSON files in '/tmp' synchronously</p>
133
+ .find();
134
+ </code></pre>
135
+ <h4>Search synchronously</h4>
136
+ <p>Find all JSON files in '/tmp' synchronously</p>
111
137
  <pre class="prettyprint source lang-js"><code>const jsonFiles = FileHound.create()
112
138
  .paths('/tmp')
113
139
  .ext('json')
114
- .findSync();</code></pre><h4>Using callbacks</h4><p>Find all empty text files in /tmp:</p>
140
+ .findSync();
141
+ </code></pre>
142
+ <h4>Using callbacks</h4>
143
+ <p>Find all empty text files in /tmp:</p>
115
144
  <pre class="prettyprint source lang-js"><code>FileHound.create()
116
145
  .paths('/tmp')
117
146
  .ext('txt')
118
147
  .isEmpty()
119
148
  .find((err, emptyTextFiles) => {
120
149
  console.log(emptyTextFiles);
121
- });</code></pre><h4>Including file stats information</h4><p>Configure file objects, containing <code>path</code> and <code>stats</code>:</p>
150
+ });
151
+ </code></pre>
152
+ <h4>Including file stats information</h4>
153
+ <p>Configure file objects, containing <code>path</code> and <code>stats</code>:</p>
122
154
  <pre class="prettyprint source lang-js"><code>const results = FileHound.create()
123
155
  .paths('/tmp')
124
156
  .ext('txt')
125
157
  .includeFileStats()
126
158
  .find();
127
159
 
128
- console.log(results) // `results` is an array of file objects</code></pre><h4>Binding to match, error and end events</h4><p>Bind to a 'match' event to process each file on match:</p>
160
+ console.log(results) // `results` is an array of file objects
161
+ </code></pre>
162
+ <h4>Binding to match, error and end events</h4>
163
+ <p>Bind to a 'match' event to process each file on match:</p>
129
164
  <pre class="prettyprint source lang-js"><code>const filehound = FileHound.create();
130
165
  filehound.find();
131
166
 
@@ -139,7 +174,10 @@ const jsonFiles = FileHound.create()
139
174
 
140
175
  filehound.on('end', (file) => {
141
176
  console(`search complete`);
142
- });</code></pre><h4>Find files by matching content</h4><p>See <a href="https://github.com/nspragg/filesniffer">FileSniffer</a></p></article>
177
+ });
178
+ </code></pre>
179
+ <h4>Find files by matching content</h4>
180
+ <p>See <a href="https://github.com/nspragg/filesniffer">FileSniffer</a></p></article>
143
181
  </section>
144
182
 
145
183
 
@@ -152,7 +190,7 @@ const jsonFiles = FileHound.create()
152
190
  <br class="clear">
153
191
 
154
192
  <footer>
155
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Mon Jan 28 2019 16:48:23 GMT+0000 (GMT) using the Minami theme.
193
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.5</a> on Wed Aug 05 2020 13:26:06 GMT+0200 (Central European Summer Time) using the Minami theme.
156
194
  </footer>
157
195
 
158
196
  <script>prettyPrint();</script>
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from "events";
2
- import Bluebird from "bluebird";
2
+ import * as Bluebird from "bluebird";
3
3
 
4
4
  declare module 'filehound' {
5
5
  class FileHound extends EventEmitter {
@@ -105,7 +105,7 @@ declare module 'filehound' {
105
105
  * .find()
106
106
  * .each(console.log);
107
107
  */
108
- public addFilter(filter: (...any) => boolean): FileHound;
108
+ public addFilter(filter: (...args: any[]) => boolean): FileHound;
109
109
 
110
110
  /**
111
111
  * Defines the search paths
@@ -124,7 +124,7 @@ declare module 'filehound' {
124
124
  * .find()
125
125
  * .each(console.log);
126
126
  */
127
- public paths(...paths: string[]): FileHound;
127
+ public paths(...paths: string[] | [string[]]): FileHound;
128
128
 
129
129
  /**
130
130
  * Define the search path
package/lib/filehound.js CHANGED
@@ -415,8 +415,22 @@ var FileHound = function (_EventEmitter) {
415
415
  }
416
416
 
417
417
  /**
418
- * Same as glob
419
- * @see glob
418
+ * Filter by a file glob
419
+ *
420
+ * @memberOf FileHound
421
+ * @instance
422
+ * @method
423
+ * match
424
+ * @param {array} glob - array of globs
425
+ * @return a FileHound instance
426
+ * @example
427
+ * import FileHound from 'filehound';
428
+ *
429
+ * const filehound = FileHound.create();
430
+ * filehound
431
+ * .match(['*tmp*']) // .match('*tmp*')
432
+ * .find()
433
+ * .each(console.log); // array of files names all containing 'tmp'
420
434
  */
421
435
 
422
436
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "filehound",
3
- "version": "1.17.3",
3
+ "version": "1.17.6",
4
4
  "description": "Find files the easy way",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -48,7 +48,7 @@
48
48
  "eslint": "^4.18.2",
49
49
  "istanbul": "^0.4.4",
50
50
  "jsdoc": "^3.4.3",
51
- "mocha": "^5.1.1",
51
+ "mocha": "^5.0.0",
52
52
  "sinon": "^5.0.2"
53
53
  },
54
54
  "eslintConfig": {
@@ -84,11 +84,11 @@
84
84
  }
85
85
  },
86
86
  "dependencies": {
87
- "bluebird": "^3.5.1",
87
+ "bluebird": "^3.7.2",
88
88
  "file-js": "0.3.0",
89
- "lodash": "^4.17.10",
90
- "minimatch": "^3.0.4",
91
- "moment": "^2.22.1",
89
+ "lodash": "^4.17.21",
90
+ "minimatch": "^5.0.0",
91
+ "moment": "^2.29.1",
92
92
  "unit-compare": "^1.0.1"
93
93
  }
94
94
  }
package/test/filehound.js CHANGED
@@ -558,6 +558,18 @@ describe('FileHound', () => {
558
558
  });
559
559
  });
560
560
 
561
+ it('returns files for given match names', () => {
562
+ const query = FileHound.create()
563
+ .match(['*b.json', '*bcc.json'])
564
+ .paths(fixtureDir + '/mixed')
565
+ .find();
566
+
567
+ return query
568
+ .then((files) => {
569
+ assert.deepEqual(files.sort(), matchFiles);
570
+ });
571
+ });
572
+
561
573
  describe('.glob', () => {
562
574
  it('returns files using glob method with a single glob', () => {
563
575
  const query = FileHound.create()