dir-parser
Advanced tools
+10
-10
@@ -91,14 +91,14 @@ #!/usr/bin/env node | ||
| */ | ||
| const parsed = parse(target, { | ||
| parse(target, { | ||
| 'excludes': excludes, | ||
| 'exdPaths': exdPaths, | ||
| 'noNum': noNum | ||
| }); | ||
| /** | ||
| * The output | ||
| */ | ||
| if (!silent) { | ||
| console.log(parsed.dirTree); | ||
| } | ||
| fn.wt(output, parsed.dirTree); | ||
| }).then( | ||
| parsed => { | ||
| if (!silent) console.log(parsed.dirTree); | ||
| fn.wt(output, parsed.dirTree); | ||
| }, | ||
| error => { | ||
| console.log(fn.chalk(error.message, 'red')); | ||
| } | ||
| ); |
+4
-2
| { | ||
| "name": "dir-parser", | ||
| "version": "1.0.10", | ||
| "version": "1.1.0", | ||
| "description": "Parse a directory and generate it's structure tree.", | ||
@@ -20,3 +20,5 @@ "main": "index.js", | ||
| "dir-tree", | ||
| "directory-tree" | ||
| "directory-tree", | ||
| "dir-info", | ||
| "parse-dir" | ||
| ], | ||
@@ -23,0 +25,0 @@ "author": "CN-Tower", |
+18
-10
@@ -103,6 +103,10 @@ # Dir Parser | ||
| const target = './'; | ||
| let target = './'; | ||
| let excludes = [ '.git', 'dir-info.txt', 'package-lock.json' ]; | ||
| let parsed = parse(target, { | ||
| /** | ||
| * Get parsed dir-tree | ||
| * ============================================================ | ||
| */ | ||
| parse(target, { | ||
| excludes: excludes, | ||
@@ -112,9 +116,13 @@ // dirTree: false, // Default is true, parsed conatins a string of directory structure truee; | ||
| // files: true, // Default is false, If true, parsed will conatins an array of all subfiles's info; | ||
| }).then(parsed => { | ||
| fn.log(parsed.dirTree, '# parsed.dirTree'); | ||
| fn.log(fn.pick(parsed, prop => prop !== 'dirTree'), '# parsed result info'); | ||
| // fn.log(parsed.members, '# parsed.members'); | ||
| // fn.log(parsed.files, '# parsed.files'); | ||
| }); | ||
| fn.log(parsed.dirTree, '# parsed.dirTree'); | ||
| fn.log(fn.pick(parsed, prop => prop !== 'dirTree'), '# parsed result info'); | ||
| // fn.log(parsed.members, '# parsed.members'); | ||
| // fn.log(parsed.files, '# parsed.files'); | ||
| /** | ||
| * Get parsed dir-info (members & files) | ||
| * ============================================================ | ||
| */ | ||
| excludes = ['.git', 'node_modules', 'dir-info.txt', 'package-lock.json']; | ||
@@ -126,6 +134,6 @@ parsed = parse(target, { | ||
| members: true | ||
| }).then(parsed => { | ||
| fn.log(parsed.members, '# parsed.members'); | ||
| fn.log(parsed.files, '# parsed.files'); | ||
| }); | ||
| fn.log(parsed.members, '# parsed.members'); | ||
| fn.log(parsed.files, '# parsed.files'); | ||
| ``` | ||
@@ -132,0 +140,0 @@ > $ node test.js |
+16
-1
@@ -6,2 +6,17 @@ const fs = require('fs'); | ||
| /** | ||
| * Export a dir-parser promise | ||
| * @param target string | ||
| * @param options object | ||
| */ | ||
| module.exports = (target, options) => { | ||
| return new Promise((resolve, reject) => { | ||
| try { | ||
| resolve(dirParser(target, options)); | ||
| } catch (err) { | ||
| reject(err); | ||
| } | ||
| }); | ||
| }; | ||
| /** | ||
| * Parse the target directory and generate it's structure tree. | ||
@@ -11,3 +26,3 @@ * @param target string | ||
| */ | ||
| module.exports = function (target, options = {}) { | ||
| function dirParser(target, options = {}) { | ||
| if (!fs.statSync(target).isDirectory()) { | ||
@@ -14,0 +29,0 @@ throw new Error('Target must be a directory!') |
+18
-9
| const fn = require('funclib'); | ||
| const parse = require('./index'); | ||
| const target = './'; | ||
| let target = './'; | ||
| let excludes = [ '.git', 'dir-info.txt', 'package-lock.json' ]; | ||
| let parsed = parse(target, { | ||
| /** | ||
| * Get parsed dir-tree | ||
| * ============================================================ | ||
| */ | ||
| parse(target, { | ||
| excludes: excludes, | ||
@@ -12,9 +16,13 @@ // dirTree: false, // Default is true, parsed conatins a string of directory structure truee; | ||
| // files: true, // Default is false, If true, parsed will conatins an array of all subfiles's info; | ||
| }).then(parsed => { | ||
| fn.log(parsed.dirTree, '# parsed.dirTree'); | ||
| fn.log(fn.pick(parsed, prop => prop !== 'dirTree'), '# parsed result info'); | ||
| // fn.log(parsed.members, '# parsed.members'); | ||
| // fn.log(parsed.files, '# parsed.files'); | ||
| }); | ||
| fn.log(parsed.dirTree, '# parsed.dirTree'); | ||
| fn.log(fn.pick(parsed, prop => prop !== 'dirTree'), '# parsed result info'); | ||
| // fn.log(parsed.members, '# parsed.members'); | ||
| // fn.log(parsed.files, '# parsed.files'); | ||
| /** | ||
| * Get parsed dir-info (members & files) | ||
| * ============================================================ | ||
| */ | ||
| excludes = ['.git', 'node_modules', 'dir-info.txt', 'package-lock.json']; | ||
@@ -26,5 +34,6 @@ parsed = parse(target, { | ||
| members: true | ||
| }).then(parsed => { | ||
| fn.log(parsed.members, '# parsed.members'); | ||
| fn.log(parsed.files, '# parsed.files'); | ||
| }); | ||
| fn.log(parsed.members, '# parsed.members'); | ||
| fn.log(parsed.files, '# parsed.files'); |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
99658
0.92%319
8.87%457
1.78%