Comparing version 0.0.2 to 0.0.3
22
index.js
@@ -7,2 +7,4 @@ const fs = require('fs'); | ||
const rxSep = new RegExp(`[${path.sep}.]`); | ||
const Smangle = require("string-mangle"); | ||
const util = require("util"); | ||
function isDirectory(filename) { | ||
@@ -69,2 +71,19 @@ return fs.statSync(filename).isDirectory(); | ||
}; | ||
/** | ||
* Make file object obtained to require calls | ||
* @param {[type]} source [description] | ||
* @param {[type]} ext [description] | ||
* @return {[type]} [description] | ||
*/ | ||
function getRequiredFile(source,ext){ | ||
const files = getFiles(source,ext,true); | ||
// console.log("stringifyTree return--->",Smangle.stringifyTree(files)); | ||
return Smangle.stringifyTree(files); | ||
} | ||
/** | ||
* Traverse file object to get filename | ||
* @param {[type]} filesTree [description] | ||
* @param {Function} fn [description] | ||
* @return {[type]} [description] | ||
*/ | ||
function traverse(filesTree, fn) { | ||
@@ -82,3 +101,4 @@ Object.keys(filesTree).forEach((key) => { | ||
getFiles, | ||
traverse | ||
traverse, | ||
getRequiredFile | ||
} |
{ | ||
"name": "grob-files", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Find files with special suffix in one or many folders", | ||
@@ -8,2 +8,3 @@ "main": "index.js", | ||
"ramda": "^0.23.0", | ||
"string-mangle": "0.0.4", | ||
"winpath": "^0.0.1" | ||
@@ -10,0 +11,0 @@ }, |
@@ -68,2 +68,22 @@ ### Install | ||
(3)getRequiredFile(source,suffix) | ||
Source and suffix as described above. Invoke this method you will get something like bellow: | ||
```js | ||
{ | ||
'filelists': { | ||
'hello': require('C:/Users/Administrator/Desktop/find-files/filelists/hello.md'), | ||
'index': require('C:/Users/Administrator/Desktop/find-files/filelists/index.md'), | ||
'md': { | ||
'fol': { | ||
'index': require('C:/Users/Administrator/Desktop/find-files/filelists/md/fol/index.md') | ||
}, | ||
'index': require('C:/Users/Administrator/Desktop/find-files/filelists/md/index.md') | ||
} | ||
} | ||
} | ||
``` | ||
5774
96
89
3
+ Addedstring-mangle@0.0.4
+ Addedstring-mangle@0.0.4(transitive)