dir-parser
Advanced tools
+2
-2
| { | ||
| "name": "dir-parser", | ||
| "version": "2.1.2", | ||
| "version": "2.1.3", | ||
| "description": "Parse a directory and generate it's structure tree.", | ||
@@ -47,4 +47,4 @@ "main": "index.js", | ||
| "commander": "^2.20.3", | ||
| "funclib": "^4.1.3" | ||
| "funclib": "^6.0.1" | ||
| } | ||
| } |
+19
-27
@@ -40,4 +40,3 @@ <h1 align="center">😎 文件夹解析器[Dir Parser v2] 😎</h1> | ||
| - [2.3.15 配置文件-config](#2315-配置文件-config) | ||
| - [2.4 文件名称包含空格](#24-文件名称包含空格) | ||
| - [2.5 多个命令混合使用](#25-多个命令混合使用) | ||
| - [2.4 多个命令混合使用](#24-多个命令混合使用) | ||
| - [三、在Js代码中使用](#三在Js代码中使用) | ||
@@ -158,2 +157,19 @@ - [3.1 方法接口](#31-方法接口) | ||
| ``` | ||
| 文件或文件名称中包含空格:<br> | ||
| `$ touch 'white space.txt'`<br> | ||
| `$ parser -e '[".git", "node_modules", "public", "white space.txt"]'` | ||
| ``` | ||
| myapp ( directories: 3, Files: 8 ) | ||
| ├─ bin | ||
| │ └─ www | ||
| ├─ routes | ||
| │ ├─ index.js | ||
| │ └─ users.js | ||
| ├─ views | ||
| │ ├─ error.jade | ||
| │ ├─ index.jade | ||
| │ └─ layout.jade | ||
| ├─ app.js | ||
| └─ package.json | ||
| ``` | ||
@@ -402,27 +418,3 @@ #### 2.3.2 忽略项-ignores | ||
| ### 2.4 文件名称包含空格 | ||
| `touch 'white space.txt'`<br> | ||
| `parser -e '["node_modules", "white space.txt"]'` | ||
| ``` | ||
| myapp ( directories: 7, Files: 10 ) | ||
| ├─ bin | ||
| │ └─ www | ||
| ├─ public | ||
| │ ├─ images/ | ||
| │ ├─ javascripts/ | ||
| │ └─ stylesheets | ||
| │ └─ style.css | ||
| ├─ routes | ||
| │ ├─ index.js | ||
| │ └─ users.js | ||
| ├─ views | ||
| │ ├─ error.jade | ||
| │ ├─ index.jade | ||
| │ └─ layout.jade | ||
| ├─ app.js | ||
| ├─ package.json | ||
| └─ parser.conf.json | ||
| ``` | ||
| ### 2.5 多个命令混合使用 | ||
| ### 2.4 多个命令混合使用 | ||
| `parser -e node_modules,bin -I views -d 2 -Nr` | ||
@@ -429,0 +421,0 @@ ``` |
+19
-27
@@ -40,4 +40,3 @@ <h1 align="center">😎 Dir Parser v2 😎</h1> | ||
| - [2.3.15 config](#2315-config) | ||
| - [2.4 Name has white space](#24-name-has-white-space) | ||
| - [2.5 Use multiple commands together](#25-use-multiple-commands-together) | ||
| - [2.4 Use multiple commands together](#24-use-multiple-commands-together) | ||
| - [3. In JavaScript](#3-in-javascript) | ||
@@ -158,2 +157,19 @@ - [3.1 Interface](#31-interface) | ||
| ``` | ||
| Name has white space:<br> | ||
| `$ touch 'white space.txt'`<br> | ||
| `$ parser -e '[".git", "node_modules", "public", "white space.txt"]'` | ||
| ``` | ||
| myapp ( directories: 3, Files: 8 ) | ||
| ├─ bin | ||
| │ └─ www | ||
| ├─ routes | ||
| │ ├─ index.js | ||
| │ └─ users.js | ||
| ├─ views | ||
| │ ├─ error.jade | ||
| │ ├─ index.jade | ||
| │ └─ layout.jade | ||
| ├─ app.js | ||
| └─ package.json | ||
| ``` | ||
@@ -402,27 +418,3 @@ #### 2.3.2 ignores | ||
| ### 2.4 Name has white space | ||
| `touch 'white space.txt'`<br> | ||
| `parser -e '["node_modules", "white space.txt"]'` | ||
| ``` | ||
| myapp ( directories: 7, Files: 10 ) | ||
| ├─ bin | ||
| │ └─ www | ||
| ├─ public | ||
| │ ├─ images/ | ||
| │ ├─ javascripts/ | ||
| │ └─ stylesheets | ||
| │ └─ style.css | ||
| ├─ routes | ||
| │ ├─ index.js | ||
| │ └─ users.js | ||
| ├─ views | ||
| │ ├─ error.jade | ||
| │ ├─ index.jade | ||
| │ └─ layout.jade | ||
| ├─ app.js | ||
| ├─ package.json | ||
| └─ parser.conf.json | ||
| ``` | ||
| ### 2.5 Use multiple commands together | ||
| ### 2.4 Use multiple commands together | ||
| `parser -e node_modules,bin -I views -d 2 -Nr` | ||
@@ -429,0 +421,0 @@ ``` |
+24
-24
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const fn = require('funclib'); | ||
| const { drop, typeVal, typeOf, get, isNum } = require('funclib/lib'); | ||
| const { DirInfo, FileInfo, calcSizekb } = require('./base'); | ||
@@ -31,3 +31,3 @@ | ||
| function fmtMatchs(exs) { | ||
| return fn.drop(exs.map(ex => fn.typeVal(ex, 'str'))); | ||
| return drop(exs.map(ex => typeVal(ex, 'str'))); | ||
| } | ||
@@ -40,3 +40,3 @@ | ||
| function fmtPaths(pts) { | ||
| return fn.drop(pts.map(ex => fn.typeVal(ex, 'str') ? path.resolve(ex) : '')); | ||
| return drop(pts.map(ex => typeVal(ex, 'str') ? path.resolve(ex) : '')); | ||
| } | ||
@@ -49,6 +49,6 @@ | ||
| function fmtPatterns(ptns) { | ||
| return fn.drop(ptns.map(ptn => { | ||
| if (fn.typeOf(ptn, 'ptn')) { | ||
| return drop(ptns.map(ptn => { | ||
| if (typeOf(ptn, 'ptn')) { | ||
| return ptn; | ||
| } else if (fn.typeVal(ptn, 'str')) { | ||
| } else if (typeVal(ptn, 'str')) { | ||
| return new RegExp(ptn.replace(/(\*?)\.([\w\d]*\$+)$/, () => `${RegExp.$1 && '\.*' || ''}\.${RegExp.$2}`)); | ||
@@ -71,21 +71,21 @@ } else { | ||
| let depth = fn.get(options, 'depth', 'num'); | ||
| if (!fn.isNum(depth)) depth = 0; | ||
| let depth = get(options, 'depth', 'num'); | ||
| if (!isNum(depth)) depth = 0; | ||
| const isReverse = fn.get(options, 'reverse', 'bol'); | ||
| const isFileFirst = fn.get(options, 'fileFirst', 'bol'); | ||
| const isFileOnly = fn.get(options, 'fileOnly', 'bol'); | ||
| const isDirOnly = isFileOnly ? false : fn.get(options, 'dirOnly', 'bol'); | ||
| const isHideDirInfo = !fn.get(options, 'dirInfo', 'bol'); | ||
| const isGetFiles = fn.get(options, 'getFiles', 'bol'); | ||
| const isGetChildren = fn.get(options, 'getChildren', 'bol'); | ||
| const isGetDirTree = fn.typeOf(options.dirTree, 'bol') ? options.dirTree : true; | ||
| const lineType = fn.get(options, 'lineType', 'str') || 'solid'; | ||
| const excludes = fmtMatchs(fn.get(options, 'excludes', 'arr') || []); | ||
| const excPaths = fmtPaths(fn.get(options, 'excPaths', 'arr') || []); | ||
| const excPatterns = fmtPatterns(fn.get(options, 'excPatterns', 'arr') || []); | ||
| const ignores = fmtMatchs(fn.get(options, 'ignores', 'arr') || []); | ||
| const includes = fmtMatchs(fn.get(options, 'includes', 'arr') || []); | ||
| const paths = fmtPaths(fn.get(options, 'paths', 'arr') || []); | ||
| const patterns = fmtPatterns(fn.get(options, 'patterns', 'arr') || []); | ||
| const isReverse = get(options, 'reverse', 'bol'); | ||
| const isFileFirst = get(options, 'fileFirst', 'bol'); | ||
| const isFileOnly = get(options, 'fileOnly', 'bol'); | ||
| const isDirOnly = isFileOnly ? false : get(options, 'dirOnly', 'bol'); | ||
| const isHideDirInfo = !get(options, 'dirInfo', 'bol'); | ||
| const isGetFiles = get(options, 'getFiles', 'bol'); | ||
| const isGetChildren = get(options, 'getChildren', 'bol'); | ||
| const isGetDirTree = typeOf(options.dirTree, 'bol') ? options.dirTree : true; | ||
| const lineType = get(options, 'lineType', 'str') || 'solid'; | ||
| const excludes = fmtMatchs(get(options, 'excludes', 'arr') || []); | ||
| const excPaths = fmtPaths(get(options, 'excPaths', 'arr') || []); | ||
| const excPatterns = fmtPatterns(get(options, 'excPatterns', 'arr') || []); | ||
| const ignores = fmtMatchs(get(options, 'ignores', 'arr') || []); | ||
| const includes = fmtMatchs(get(options, 'includes', 'arr') || []); | ||
| const paths = fmtPaths(get(options, 'paths', 'arr') || []); | ||
| const patterns = fmtPatterns(get(options, 'patterns', 'arr') || []); | ||
@@ -92,0 +92,0 @@ let dirTree = ''; |
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
565594
0.38%918
-0.86%+ Added
- Removed
- Removed
Updated